Need help with simple script
4 posts • Page 1 of 1
Need help with simple script
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
//Rideg
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Need help with simple script
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:
So now every time the circle collides with the box the position of the collision event will be stored to scene.my.position.
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.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Need help with simple script
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:
That will be constantly updated with scene.my.position and you don't have to make it collide with anything!
- 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!
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
4 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 16 guests