XxRQxX
1
I added an animation to my destroy script of the bullet- the bullet gets destroyed but the animation just replays over and over, I want it to destroy on collision as well… here is the destroy script of the bullet
using UnityEngine;
using System.Collections;
public class Destroyer : MonoBehaviour
{
public bool destroyOnAwake;
public float awakeDestroyDelay;
public bool findChild = false;
public string namedChild;
void Awake ()
{
// If the gameobject should be destroyed on awake,
if(destroyOnAwake)
{
if(findChild)
{
Destroy (transform.Find(namedChild).gameObject);
}
else
{
// ... destroy the gameobject after the delay.
Destroy(gameObject, awakeDestroyDelay);
}
}
}
void DestroyChildGameObject ()
{
// Destroy this child gameobject, this can be called from an Animation Event.
if(transform.Find(namedChild).gameObject != null)
Destroy (transform.Find(namedChild).gameObject);
}
void DisableChildGameObject ()
{
// Destroy this child gameobject, this can be called from an Animation Event.
if(transform.Find(namedChild).gameObject.activeSelf == true)
transform.Find(namedChild).gameObject.SetActive(false);
}
void DestroyGameObject ()
{
// Destroy this gameobject, this can be called from an Animation Event.
Destroy (gameObject);
}
}
Tell the Animator Controller to be disabled once the GameObject is destroyed.