I have 3 different projects all using the same scripts/setup except now I’ve added in the universal rp to one of them. Mind you they are all setup the same except the rp. I’ve got my persistent scene with my additive scene loading in on play.
When the player is loading in at position 0,0,0. Everything works in my other 2 projects and loads correctly with no issues. The project with the rp in it when I press play to test it keeps loading and unloading my additive scene constantly. If I try to move the player around eventually it stops and loads the scene to where I can move around, but if I go back to position 0,0,0 it goes right back to unloading and loading. I even tried a test build but it only crashes. Try as I might I’m not knowledgeable enough to even figure out what is causing it to happen since no errors pop up and neither of the other 2 projects have this issue.
Now if they player begins at any other position and as long as they don’t run over 0,0,0 everything is fine. I’m totally lost and confused. Please help enlighten me.
There may be code detecting the player is there and triggering those scene loads.
To reason about what is happening, find all the places in the code that might load a scene, usually with the UnityEngine.SceneManagement class.
Whatever it is, you must find a way to get the information you need in order to reason about what the problem is.
What is often happening in these cases is one of the following:
the code you think is executing is not actually executing at all
the code is executing far EARLIER or LATER than you think
the code is executing far LESS OFTEN than you think
the code is executing far MORE OFTEN than you think
the code is executing on another GameObject than you think it is
To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.
Doing this should help you answer these types of questions:
is this code even running? which parts are running? how often does it run? what order does it run in?
what are the values of the variables involved? Are they initialized? Are the values reasonable?
are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)
Knowing this information will help you reason about the behavior you are seeing.
You can also put in Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene
You could also just display various important quantities in UI Text elements to watch them change as you play the game.
If you are running a mobile device you can also view the console output. Google for how on your particular mobile target.
Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.
Here’s an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:
Also, so you know, Scene loading/unloading has nothing to do with 2D and this forum is for 2D features. Maybe a more appropriate forum might be the scripting forum.
I can move your post there where you’re likely to get more eyes on your post.