Missing reference on loadLevel when the object exist...why? :(
When I call LoadLevel(level), every level have an object called Traveller, I suppose that on-loading, the last level was destroyed and new level load all object that contain the new scene, I dont undestand why getComponent cant find my script attached to my Traveller object, if this exist in the new scene. here is an screenshot:
void Start () {
traveller = GameObject.FindGameObjectWithTag("Traveller").transform;
travellerController = traveller.GetComponent<TravellerController> ();
GameController isDontDestryOnLoad, right? run your above code on Start not Awake.
At first it was on start, but the problem persist :(
Answer by Baste · Sep 25, 2015 at 06:41 PM
Start is only called once.
This means that if you have an object that's DontDestroyOnLoad-ed, it won't call Start again when you change your scene.
So your GameController is still referencing the now-destroyed traveller from the last scene.
To fix this, call the same code as you're calling in Start in OnLevelWasLoaded.
EDIT: Also don't post questions with all-caps headlines, as that's super-annoying, and more likely to have people ignore your question than answering it.
Yeah, sorry about caps :P. I think the problem is in the design, because every scene has a gamecontroller ( levelcontroller ). So I will change to masterController (make this one persistant in all scenes ) and maybe fix this issue, thanks mate :)
Your answer
![](https://koobas.hobune.stream/wayback/20220612034950im_/https://answers.unity.com/themes/thub/images/avi.jpg)