Cannot instantiate objects with a parent, error blocker

Hello!

I seem to have found myself stuck. I feel as though I followed everything pretty closely, however I am experiencing this error whenever Spawn is called from takeDamage.

Cannot instantiate objects with a parent which is persistent. New object will be created without a parent.
UnityEngine.Object:Instantiate<RPG.UI.DamageText> (RPG.UI.DamageText,UnityEngine.Transform)

Does anyone have any idea, or has experienced this and found a solution? Thank you :slight_smile:

It’s most likely that you have selected an in scene object instead of a prefab for the damageTextPrefab.

Thanks for the reply Brian.

As far as I’m aware, I am using the correct prefab, and not using a scene item.

I.E. I drag from the Project Browser directory straight into the inspector slot. I drag a prefab that is made of an (Empty GameObject >> Canvas >> Text), where the DamageText script lives on the Empty GameObject).

Paste in your Damage Text Spawner script, and and I’ll have a look.

Hopefully this is sufficient.

Ok, that looks right.

Open up your Player in Prefab edit mode, and go to the Health component. In the event that calls DamageTextSpawner, click on the text of the Object picker (not the little circle)… make sure it’s calling the DamageTextSpawner that’s a child of the Player, not the prefab in the scene. (Sort of the opposite problem of the first solution).

1 Like

That was it!

Wow, impressive debug skills! I don’t know if I would’ve figured that one out.

Thanks for the super fast reply Brian, appreciate that.

1 Like

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

Privacy & Terms