Question by
BlackEagle0 · Mar 11, 2016 at 06:47 PM ·
animationscript.animations
How do you get an animation to not start automatically?
I've been making a 3D FPS Game and made a walking animation where the gun swings up and down. But, whenever I enter play mode, before pressing any buttons, the walking animation just starts. How do I not make it start automatically and make it start/stop playing when the user starts/stops pressing "w"?
Here is my current Walking Script:
function Update(){
//** OPTION A **
if(Input.GetKeyDown(KeyCode.W)){
walking = true;
//play WalkingAnimation
}
if(Input.GetKeyUp(KeyCode.W) && walking){
walking = false;
//play idle
} }
I also tried this script but the same issue occurred:
function Update()
{
if(Input.GetKeyDown("w"))
{
// Plays the WalkingAnimation animation - stops all other animations
GetComponent.<Animation>().Play("WalkingAnimation", PlayMode.StopAll);
}
}
Thanks!
Comment
Your answer
Follow this Question
Related Questions
Animation only plays in one of the objects 1 Answer
I need help writing a script that triggers a character animation when entering a collider 0 Answers
Onde encontro a pasta "projet's assets"? 0 Answers
Walking animation of character appear broken when combined with NavMesh Agent 0 Answers
Moving an Object to a random position 3 Answers