When my player respawns “prefab” it can not find the script property “Root”
The only way i can solve this is too put it inside the prefab, the only downfall
is that all my items i pick up into my Inventory gets deleted, because it respawns
the whole inventory. Can any body help ?
Instead of destroying and re-instating the player, just disable and re-enable it.
Prefabs cannot contain links to objects outside of the prefab, because they are not tied to any specific scene.
You could assign a reference to the player from script after you instantiate them.
Or instead of instantiating a copy of a prefab, you could instantiate a copy of some object that’s already in your scene (which allows your “template” to have links to other stuff in your scene).
Cucci_A’s suggestion of disabling the player instead of destroying them might also be effective, depending on your circumstances.
Thank you for your suggestions. I might not add a respawn system, because a horror game rarely does that
it usually punishes the player for dying.
What do you mean by disabling, can you give me a example please.
I`m new to unity and have come from blender game engine which i spent 8 years on.
You can use SetActive() to make an object (and all of its scripts, and all of its children) temporarily disappear.
Though in the case of respawning, you may really just want to move the player to the spawn point…