- Home /
Need help with a move object script
I dont have a full script written but before i go and mess up everything i would like to hear what you guys think.
I would like to be able to jump on a cube and push it down on the y-axis ONLY once so that way the cube dosent keep going down.
Then when i jump off the cube it goes back to it original position.
The one thing i dont want to see is when i jump on and off the cube, the cube quickly goes to the positions. I would like the cube to slowly go up and down with a variable.
I know this is a lot at once and with out a script but i am very new to scipting as well this site so if anyone can help that would be great, any suggestions at all. THANKS
Answer by Qamar · Mar 11, 2011 at 04:59 AM
Well, I've not implemented the thing like this but I can suggest you the method,
You can make some variables and flags like
var goDownSpeed: float var isFallenOn: boolean; private downDistance: float; private var originalPosition: Vector3;
Now in the function OnCollisionEnter() you can set the isFallenOn and make make the object( which is fallen on the cube) the child of the cube and then use the transform.Translate function for the cube to go down upto the downDistance you set from the editor. You can unchile the object when you click or whatever you want and then use the same transform.Translate for the cube to go back to original y-axis value.
I hope you get help from this
Your answer
Follow this Question
Related Questions
move till collision 1 Answer
Looking at an Object (y-axis included) 1 Answer
Updating an array indices dynamically 2 Answers
Vector3.lerp doesn't work 1 Answer
moving an object with swipe for ios? 3 Answers