- Home /
Question by
asscock · Aug 23, 2014 at 06:23 PM ·
animationjavascriptmecanim
Attack Animation through Javascript
Hi, I need to make sure the attack can only play, while in the attackidle stance on mecanim. any ideas? heres script. #pragma strict internal var animator : Animator; var hor : float; var ver : float; private var draw: boolean = false; private var attack: boolean = false;
function Start () {
animator = GetComponent(Animator);
}
function Update (){
hor = Input.GetAxis("Horizontal");
ver = Input.GetAxis("Vertical");
}
function FixedUpdate(){
animator.SetFloat("walking", ver);
if(Input.GetKeyDown(KeyCode.LeftShift)) {
animator.SetBool("draw", true);
}
if(Input.GetKeyUp(KeyCode.LeftShift)){
animator.SetBool("draw", false);
if(Input.GetKeyDown("t") && Input.GetKey("t")){
animator.SetBool("attack", true);
}
if(Input.GetKeyUp("t")){
animator.SetBool("attack", false);
}
}
}
using Booleans, I apologize in advance for poor english.
Comment
Your answer
Follow this Question
Related Questions
Animation depending on the Int value 0 Answers
Controlling Mecanim through javascript? 2 Answers
Mecanim not updating script when it switches state? 2 Answers
How to get the values of the animation? 0 Answers