MissingReferenceException after instantiating as Child

Hi,

After modifying AttackerSpawner to

    private void SpawnAttacker()
    {
        Attacker newAttacker = Instantiate(attacker, transform.position, transform.rotation) as Attacker;
        newAttacker.transform.parent = transform;
    }

I get a MissingReferenceException,

MissingReferenceException: The object of type 'Attacker' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.

I’m not quite sure what’s wrong? Been following Ricks code along…

Thanks!

Hi Alexander,

Welcome to our community! :slight_smile:

Is a game object from the Assets folder assigned to the attacker variable?

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms