I’ve made a Animation and put it on a Game Object. When I press and hold down “w” it will play. But when I let the “w” button go, The Game Object stops at that position. I want it to go back to it’s original position. What is the original position? It’s the position that the Game Object usaly are in. How do I get it back to it’s original position?
Perhaps you should wait longer than half an hour before panicking and screaming “HELP!”
This is the easiest way I can think of:
private vector3 originalPos;
public Transform myTrans;
//in start()
myTrans=transform;
originalPos= myTrans.position;
//when "W" isreleased
myTrans.position=originalPos
This will basically “teleport” the transform it is attached to back to the position it was at the start.
NOTE: This is NOT a complete script in any way. Just showing you the basics of what you need to do.
I’m new to Unity, Is there any website where I can find a complete script? And when I got the script what should I do with the it? Attach it to the Game objects or what?[quote=“drewradley, post:2, topic: 523115, username:drewradley”]
Perhaps you should wait longer than half an hour before panicking and screaming “HELP!”
This is the easiest way I can think of:
private vector3 originalPos;
public Transform myTrans;
//in start()
myTrans=transform;
originalPos= myTrans.position;
//when "W" isreleased
myTrans.position=originalPos
This will basically “teleport” the transform it is attached to back to the position it was at the start.
NOTE: This is NOT a complete script in any way. Just showing you the basics of what you need to do.
[/quote]
Any help?