tutorial for VERY EASY MOUSE POINTER
Posted: Thu Jan 06, 2011 4:56 pm
Hi i'm jesse and if you've got a problem with the "complicated" math scenes of kilinich (not meant bad for you kilinich )
one scene is a mouse pointer like his servo motors, i don't understand s*** about whats the script says
i came up with an idea myself to make a mouse follower that needs only 2 variables
the following script is very easy, i will first explain it to you:
if you make a "aiming hinge with box" (so like the part on a gun that twists when aiming).
it's important it lays FLAT on the ground, so it's not higher than it's wide, then make a laser (only collideset B) and make a small box (also collideset B), make the laser point at the box and set it close to it, now select them both and copy it with "CTRL".
if you've done right you now have 2 lasers and 2 boxes
select 1 laser and the box it's pointing at and put them ON the aiming box, NOT IN THE MIDDLE BUT IN THE CORNER... now take the second laser and box and do the same
example: but laser+box in the top left corner of that box and the other laser+box in the DOWN LEFT CORNER
if you dont understand check the scene, the lasers and boxes in mean are BLUE [0,1,0,1],
now fixate both boxes to the aiming box.
then: select the lasers and type in the onlaserhit:
that is the code for distance calculation (using the law on pytagoras: a^2+b^2=c^2)
now, put in the console:
then, put in one laser next to the pytagoras code using ; the following:
put in the OTHER laser the same but now we use the second part of the array, so it will be number2. it looks like this:
a COMPLETE CODE of 1 la2er (caution: the 2 lasers are almost but NOT the same):
now you're almost done, the only thing you have to do is make a hinge
make a hinge at the rotation box, set motor TRUE and torque to +inf
then, set the motorspeed IN THE SCRPIT MENU OF THE HINGE to:
now you are done, check this scene of me and if it's practically the same as you made... then you are a hero and have succes
PLZ COMMENT AND RATE, any questions? email me at jesse_bax@live.nl. nederlands? email gwn met nederlands taal haha
one scene is a mouse pointer like his servo motors, i don't understand s*** about whats the script says
i came up with an idea myself to make a mouse follower that needs only 2 variables
the following script is very easy, i will first explain it to you:
if you make a "aiming hinge with box" (so like the part on a gun that twists when aiming).
it's important it lays FLAT on the ground, so it's not higher than it's wide, then make a laser (only collideset B) and make a small box (also collideset B), make the laser point at the box and set it close to it, now select them both and copy it with "CTRL".
if you've done right you now have 2 lasers and 2 boxes
select 1 laser and the box it's pointing at and put them ON the aiming box, NOT IN THE MIDDLE BUT IN THE CORNER... now take the second laser and box and do the same
example: but laser+box in the top left corner of that box and the other laser+box in the DOWN LEFT CORNER
if you dont understand check the scene, the lasers and boxes in mean are BLUE [0,1,0,1],
now fixate both boxes to the aiming box.
then: select the lasers and type in the onlaserhit:
- Code: Select all
(e)=>{e.laser.distance = (((e.pos(0) - app.mousepos(0)) ^ 2) + ((e.pos(1) - app.mmousepos(1)) ^ 2)) ^ 0.5}
that is the code for distance calculation (using the law on pytagoras: a^2+b^2=c^2)
now, put in the console:
- Code: Select all
scene.my.distance1 = 0 and scene.my.distance2 =0
then, put in one laser next to the pytagoras code using ; the following:
- Code: Select all
scene.my.distance1 = e.laser.distance
put in the OTHER laser the same but now we use the second part of the array, so it will be number2. it looks like this:
- Code: Select all
scene.my.distance1 = e.laser.distance
a COMPLETE CODE of 1 la2er (caution: the 2 lasers are almost but NOT the same):
- Code: Select all
(e)=>{e.laser.distance = (((e.pos(0) - app.mousepos(0)) ^ 2) + ((e.pos(1) - app.mmousepos(1)) ^ 2)) ^ 0.5;scene.my.distance1 = e.laser.distance}
now you're almost done, the only thing you have to do is make a hinge
make a hinge at the rotation box, set motor TRUE and torque to +inf
then, set the motorspeed IN THE SCRPIT MENU OF THE HINGE to:
- Code: Select all
{(scene.my.distance1 - scene.my.distance2)* "whatever you want, it will be faster but more unstable, recommended is between 10 and 20"
now you are done, check this scene of me and if it's practically the same as you made... then you are a hero and have succes
PLZ COMMENT AND RATE, any questions? email me at jesse_bax@live.nl. nederlands? email gwn met nederlands taal haha