This is a part of my C# script MovePlayer.cs :
public bool regen;
public Transform Player;
// Use this for initialization
void Start () {
regen = false;
}
void Update () {
if(Input.GetAxis("Vertical") == 0){
Player.animation.Play("idle");
}
if (Input.GetKey(KeyCode.R) && Input.GetAxis("Vertical") == 0){
regen = true;
}
if(regen){
Player.animation.Play("faint");
}
// ... Rest of my script
Firstly , my script is on an empty in this empty I have my Player, I would like to start my “regen” animation but it’s like she’s freezing… I think it’s because it’s in the Update Function and it’s called on every frame so, my question is how to play the animation “regen” just one time, by pressing the “R” on my keyboard, and get back to my “idle” animation automatically?
Thanks.
Try using !Player.animation.[IsPlaying][1] to determine if an animation is playing, and if it isn't, play. You can also use GetKeyDown, since it's only called once per Key Event (only when the user presses the key). [1]: http://docs.unity3d.com/Documentation/ScriptReference/Animation.IsPlaying.html
– DavidDebnarit does not work very well.. I'll leave this function for now,thank you all!
– Flyskyz87