Forum rules - please read before posting.

Preload and changing scene

Hi!
Maybe I'm doing this wrong, but I have a problem with preloading scene and switching scene.
This is what I do

* In scene 1 "on start", I preload scene 2.
* I test the game, the scene 2 is preloaded in hierarchy when I start scene 1.
* I walk and switch to scene 2, no problems.
* I go back to scene 1, which preloads scene 2 again (since it's done "on start")

So here is when I get an error message:
NullReferenceException: Object reference not set to an instance of an object
AC.SceneChanger+<PreloadLevelAsync>c__IteratorF.MoveNext () (at Assets/AdventureCreator/Scripts/Game engine/SceneChanger.cs:349)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)


And when I try to go back to scene 2 the game freezes up. In hierarchy I get  one extra Scene 2 loaded - so there is two in total.

I have latest AC1.54c and Unity 5.4 0f3.

Anyone got any ideas? 

Comments

  • Welcome to the forum, @DanielThomas.

    Thank you for the clear steps.  I've recreated the issue following them, but it's not yet clear if this is down to Unity or AC.  It doesn't occur, however, if you have a (very) brief pause in your OnStart Cutscene before preloading the scene.

    Try inserting an Engine: Wait Action of 0.1s at the top of your Cutscene, to give the scene a moment to initialise before you call the preload.  You can set the Cutscene to run in the background, as opposed to blocking gameplay, within the list of properties at the top of its Inspector.
  • That did the trick, thanks for the quick reply!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.