- Home /
Player Animation HELP NEEDED
Hi i just finished making an animation of a person walking and named it "walking" I also made an animation of a person standing still if have this code so far but the stand still doesnt work :/ var Walk : String = "Walking"; var stand : String = "stand"; function Start () { } function Update () { if (Input.GetKeyDown ("w")) { gameObject.animation.CrossFade(Walk); } else if (Input.GetKeyUp ("w")) { gameObject.animation.CrossFade(stand); gameObject.animation.Play(stand); } }
Answer by Kleptomaniac · Apr 11, 2012 at 11:22 AM
Try getting rid of your animation.Play(stand) line. The CrossFade should already be playing the animation.
Also, two things: 1) There really isn't any point to declaring string variables when you could just access the animations like so: animation.CrossFade("Walking"). 2) You don't need gameObject in front of your animation lines.
Hope that helps, Klep
Thanks for the help, when i did that the player animation works perfectly although when i let go it stops it at a random point and doesnt go to the standing still point, which i really wanted. I have my animation set to Loop (if that helps anymore :/) Thanks again
Your answer
Follow this Question
Related Questions
Making FPSController Stagger 0 Answers
What's the difference between animation and animator ? 0 Answers
Jump animation anticipation 2 Answers
Transition to sprint animation not working 0 Answers
walk animation script 1 Answer