when i animate something such as a door opening and closing i want the animation to start only when i click on it. at the moment it only happens once when i start the game or if i put it on loop.
please can anyone help me?
when i animate something such as a door opening and closing i want the animation to start only when i click on it. at the moment it only happens once when i start the game or if i put it on loop.
please can anyone help me?
what you need to do is something very simple. You need to add a script that at the exact moment you want you only put
animation.Play("open");
On the quotes you put the name of the animation you have.
If your case is a door I recommend you to watch this video: http://www.youtube.com/watch?v=jDgvO7wtUMg&feature=related and the others videos to.
if you mean of put a GUI put something like this:
if (GUI.Button(Rect(10,70,50,30),"open")){
animation.Play("open");
}
Or if you want something like clic in the door and then it opens you may see this: http://answers.unity3d.com/questions/28251/how-to-perform-a-mouse-click-on-game-object/28252#28252
Make a "close" animation and then a "open" animation. Then put this script on the door. It should work!
var player : Transform;
var dist = 3;
function OnMouseOver(){
if ( Vector3.Distance( door.position, transform.position ) < dist ){
if (Input.GetMouseButtonDown(0)){
animation.Play("open");
if ( Vector3.Distance( door.position, transform.position ) < dist ){
if (Input.GetMouseButtonDown(1)){
animation.Play("close");
}
}
}
Hi, How would you create a similar script for an iPhone application using touch control?
Thanks