- Home /
Question by
importguru88 · Jul 23, 2016 at 01:56 AM ·
animationlayersidhash
How do I check to see if animation layer is playing with hash id on Unity3d
I am using an hash id so I can make the enemy ai die animation work . But thing it has to gameobject has to deactivate . I am transitioning from anystate to die animation . Here is what I got for code :
protected virtual void Awake()
{
dieState = Animator.StringToHash("Base Layer.Die");
anim = GetComponent <Animator>();
m_GameObject = gameObject;
m_Transform = transform;
m_Rigidbody = GetComponent<Rigidbody>();
SharedManager.Register(this);
m_CurrentHealth = m_MaxHealth;
m_CurrentShield = m_MaxShield;
// Register for OnRespawn so the health and sheild can be reset.
EventHandler.RegisterEvent(m_GameObject, "OnRespawn", OnRespawn);
}
// Deactivate the object if requested.
if (m_DeactivateOnDeath) {
Scheduler.Schedule(m_DeactivateOnDeathDelay, Deactivate);
GetComponent<AudioSource>().Play();
anim.SetBool("isDead", false);
}
}
Comment
The animation check has to go in here : In the if statement.
if (m_DeactivateOnDeath || ) {
Scheduler.Schedule(m_DeactivateOnDeathDelay, Deactivate);
GetComponent<AudioSource>().Play();
anim.SetBool("isDead", false);
}
}
Your answer
Follow this Question
Related Questions
Animation motion on base layer does not play after additional motion on second layer 0 Answers
Can I make animations snap to a frame? 1 Answer
How to disable/override a part of an animation created in Unity 2017.4 0 Answers
Unity 2D animation layers stop other animation layers. 0 Answers
Setting Layer Weights properly 0 Answers