- Home /
This question was
closed Aug 13, 2017 at 12:05 PM by
Digestivbiscuitsm for the following reason:
The question is answered, right answer was accepted
Question by
Digestivbiscuitsm · Aug 13, 2017 at 11:31 AM ·
c#animationframes
Animation only Playing for 7 Frames
I have this script as my animation player: using UnityEngine;
public class animationPlayer : MonoBehaviour {
public Animation allAnim;
void Update () {
if (Input.GetKeyDown("w") || Input.GetKeyDown("d") || Input.GetKeyDown("s") || Input.GetKeyDown("a"))
{
GetComponent<Animation>().Play("walk");
}
else
{
GetComponent<Animation>().Stop("walk");
}
if (!Input.GetKeyDown("w") || Input.GetKeyDown("d") || Input.GetKeyDown("s") || Input.GetKeyDown("a") || Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown("space"))
{
GetComponent<Animation>().Play("idle");
}
else
{
GetComponent<Animation>().Stop("idle");
}
}
}
But whenever I go into play mode, the walk animation only plays for 7 frames when I press w, a, s or d keys and it is 110 frames long (I know that is long for a walk animation). Can anyone help? I have a video here if it will help: https://youtu.be/OqTo_aPQ0MQ
Comment
Best Answer
Answer by Digestivbiscuitsm · Aug 13, 2017 at 12:05 PM
Nevermind, I have fixed it by using GetComponent().Rewind(); when it is supposed to stop.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Check if an animation has played for a certain amount of time? 0 Answers
How to play animation (C#) 3 Answers
Animation at the end of the level 1 Answer