- Home /
This question was
closed Aug 01, 2021 at 08:48 PM by
euanross400 for the following reason:
Other
Question by
euanross400 · Jul 21, 2021 at 06:38 PM ·
animationscripting problemif-statements
Playing the right animation when running and not running
Hi I have made some code that when the player is running or not running it plays the idle or running animation, but it is a little inconsistent as some times it plays the idle animation.
This is my code, I think the second if is the only thing that needs fixed: if (Input.GetKeyDown("w") || Input.GetKeyDown("a") || Input.GetKeyDown("s") || Input.GetKeyDown("d")) { // Player is moving animator.SetBool("isRunning", true); }
if (Input.GetKeyUp("w") || Input.GetKeyUp("a") || Input.GetKeyUp("s") || Input.GetKeyUp("d"))
{
// Player is not moving
animator.SetBool("isRunning", false);
Debug.Log("Player is not moving");
}
Comment
Follow this Question
Related Questions
EditorCurveBinding.FloatCurve propertyName for scale 0 Answers
Technique to synchronize during of animation and wanted action? 0 Answers
How to make the animation run longer or shorter? 1 Answer
animation problem 1 Answer
My animation is not playing 2 Answers