- Home /
i have problem with animation play via script
i have have a rigged model of people they walk around the player i want to when i shoot they dead i put the walk animation into it in animator controller but how can i play dead animation when player shoot the people
Answer by adrienPlayerium · Jul 27, 2017 at 08:12 AM
You can use the animator.setBool("die",true) something like that. You need can add a boolean condition from any state to dead state ~
Answer by annonymushubh · Jul 27, 2017 at 08:21 AM
this my animator i take a boolean dead variable in transection walk to dead
You might want dead to be "true" when you mode to dead state. In Scripts you can modify Dead condition using animator.SetBool("Dead",true (or false))
Answer by harrismak4 · Jul 27, 2017 at 10:07 AM
You need to set transition condition "Dead" to true in inspector, in image it is false. then from script call
GetComponent<Animator>().setBool("Dead",true);
it will start dead animation.
but i did not started because i want to when the bullet hit then the dead animation on the people
Oh, then you can use the triggers to change states, have a look at animator.SetTrigger()
as harrismak4 said you can use GetComponent().setBool("Dead",true); to play your animation,you want when the bullet hit them they die,
so if(bullet hit ){ GetComponent().setBool("Dead",true);
}
and another thing make sure Has Exit Time is unchecked, you want when you shoot them they die at once not when their walking finished.
Your answer
Follow this Question
Related Questions
How to trigger the same animator state in unity5 with script? 2 Answers
Can't change transform rotation of GO with an animation that change it's rotation 3 Answers
2D Sprite Animation & 2D Image component 1 Answer
My animations are messed up 1 Answer
Trouble syncing player model animation over network 2 Answers