Question about the alternative prefab for newer Unity versions

In the ‘Using Unity events’ lecture you explain how to destroy the gameobject with the alternative hierarchy. Wouldn’t it be simpler to just put the Animation component on the root of the prefab where the script is?

You could do it either way. There are many ways to the same outcome.

This is what I did:

        public void Spawn(float damageAmount)
        {
            DamageText instance = Instantiate<DamageText>(_damageTextPrefab, transform);
            Destroy(instance.gameObject, 1f);
        }

Privacy & Terms