Go through this code. var Character : Transform; var dist = 3; function Update(){ if ( Vector3.Distance( Character.position, transform.position ) < dist ){ if (Input.GetKey("e")) Character.animation.Play("push"); animation["push"].wrapMode = WrapMode.Once; } } I put this script on a game object say cube. The variable Character is my third person player. I have a third person character animation for pushing objects. ok. the thing is if i get near the cube and press "e" key, the player animation starts to play but it plays continuously. i want it to stop after one cycle of animation. it looks like pushing the object again and again lol.
The Problem is solved. var Character : Transform; var AnimationToPlay = ""; var dist = 3; function Update(){ if ( Vector3.Distance( Character.position, transform.position ) < dist ){ if (Input.GetKey("e")){ Character.animation[AnimationToPlay].wrapMode = WrapMode.ClampForever; Character.animation.Play(AnimationToPlay); } } }
Code (csharp): var Character : Transform; var AnimationToPlay = ""; var dist = 3; function Update(){ if ( Vector3.Distance( Character.position, transform.position ) < dist ) { if (Input.GetKey("e")) { Character.animation[AnimationToPlay].wrapMode = WrapMode.ClampForever; Character.animation.Play(AnimationToPlay); } } } i guess now the tab is also a frnd...