Page 1 of 1

Need help with simple script

PostPosted: Tue Dec 15, 2009 5:30 pm
by Rideg
Hello. i've just beggining to understand how to script simple codes but I need help with binding a varaible to a object. I created a varable (scene.my.position) and want a box that is fixated on the moving "car", to show the value of scene.my.position. Please help me

//Rideg

Re: Need help with simple script

PostPosted: Tue Dec 15, 2009 6:06 pm
by KarateBrot
Ok you nearly completed it.
So now that you created scene.my.position, fixate the box to the car and make a circle next to the box. now attach the circle wit a hinge somewhere but not in the center. make the hinge a motor with +inf strength and a speed of 600rpm. the circle should now collide very often with the circle when you playback the simulation.
now go to the scripting menu of the box. you can see a line with "onCollide =" where you type in:
Code: Select all
(e) => { scene.my.position = e.pos }


So now every time the circle collides with the box the position of the collision event will be stored to scene.my.position.

Re: Need help with simple script

PostPosted: Tue Dec 15, 2009 6:14 pm
by Rideg
thank you;)

Re: Need help with simple script

PostPosted: Tue Dec 15, 2009 6:21 pm
by standardtoaster
Another way to do it is using the text variable in the box. Find the text part of the script menu of the box and put:
Code: Select all
{scene.my.position}

That will be constantly updated with scene.my.position and you don't have to make it collide with anything!