News › Forums › RAIN › General Discussion and Troubleshooting › How do I play just the death animation only
Tagged: animation death play How do I
This topic contains 0 replies, has 1 voice, and was last updated by Fail2016 2 weeks, 2 days ago.
-
AuthorPosts
-
July 23, 2022 at 5:35 pm #40513
I have my own health script . I wanna use the software to play the death animation clip , because I been having some issues the playing the clip with unity3d animator control . The gameobject has to deactivate and then play the death animation clip first. Here is a look at my health script . I also most forgot to mention . The models are a fbx file .
public bool Invincible { set { m_Invincible = value; } } public float MaxHealth { set { m_MaxHealth = value; } } public float MaxShield { set { m_MaxShield = value; } } public float CurrentHealth { get { return m_CurrentHealth; } } public float CurrentShield { get { return m_CurrentShield; } } public float ShieldRegenerativeAmount { set { m_ShieldRegenerativeAmount = value; } } public AudioClip deathClip; public bool isSinking; static Animator anim; public int dieState; void Start () { anim = GetComponent<Animator> (); }
protected virtual void Awake()
{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);
}private void DieLocal(Vector3 position, Vector3 force)
{
// Notify those interested.
EventHandler.ExecuteEvent(m_GameObject, “OnDeath”);
EventHandler.ExecuteEvent<Vector3, Vector3>(m_GameObject, “OnDeathDetails”, force, position);// Spawn any objects on death, such as an explosion if the object is an explosive barrell.
for (int i = 0; i < m_SpawnedObjectsOnDeath.Length; ++i) {
ObjectPool.Instantiate(m_SpawnedObjectsOnDeath[i], transform.position, transform.rotation);
}// Destroy any objects on death. The objects will be placed back in the object pool if they were created within it otherwise the object will be destroyed.
for (int i = 0; i < m_DestroyedObjectsOnDeath.Length; ++i) {
if (ObjectPool.SpawnedWithPool(m_DestroyedObjectsOnDeath[i])) {
ObjectPool.Destroy(m_DestroyedObjectsOnDeath[i]);} else {
Object.Destroy(m_DestroyedObjectsOnDeath[i]);
}
}// Deactivate the object if requested.
if (m_DeactivateOnDeath) {
Scheduler.Schedule(m_DeactivateOnDeathDelay, Deactivate);
GetComponent<AudioSource>().Play();
anim.SetBool(“isDead”,false);}
}
- This topic was modified 2 weeks, 2 days ago by Fail2016.
-
AuthorPosts
You must be logged in to reply to this topic.