I was wondering if it possible to have a script loaded on the next scene of the one it was originally in. In my game, i have a certain script on the Player that he needs throughtout the whole game. Thanks!
Any GameObject can be marked as persistent between scenes by calling [DontDestroyOnLoad()
][1].
If you want the rest of your Player to be “reset” between scenes (as I expect you do), then you could attach the player script to a persistent object just before scene transitions, then retrieve it once the scene load is complete.
An alternative option might be storing some values is static variables.
Well i actually dont want to keep the Player but a certain script that is attached to him in the Intro scene.
Hmm looks like the Unity website having some issues today, cant post comments here or edit my existing posts elsewhere.
But yes you can do this very easily with the don’t DontDestroyOnLoad();
However, if you are new to programming or Unity and don’t have a really good reason to not destroy it, I would avoid this. A better solution would be PlayerPrefs or using a public static variable which will survive scene transitions within the project until you exit the game I think.
This should be a comment really since DontDestroyOnLoad() is the correct answer but looks like I can only do answers at the moment.