0

Adding a Script to Check For Existing Player and Instantiate or Move

Ryan Lamb 2 years ago • updated 2 years ago 1

Hey guys,


I'm trying to figure out a good way to check for a player prefab on new level generation and then instantiate if there is none or move it if there isn't. The point of this is to replace the player prefab placement methods that already exist which destroy existing player prefabs and instantiate a new instance. I want to keep the player no matter how many new maps are generated and then just move him to the entrance when the new one is generated. I've tried several ways and I keep running into errors because I'm not connecting the scripts in the right places or its trying to reference an object that is destroyed when a new map is generated. I would really appreicate a nudge in the right direction if anyone has ideas.

I figured it out and will be happy to share the sloppy, but working solution with anyone interested.