I hate to keep bringing up these issues I'm finding, but it looks like the Engine: End game action in which the Restart Game command is used does not work properly.
I'm testing my game, and I have a death menu in which Restart Game is an option, and it calls a menu actionlist in which the only action which is run is the Engine: End Game action with the Restart Game command called to restart the game at scene 0.
Scene 0, which is just a title screen, loads correctly, but as soon as I try to move to scene 1, in which the player character should be present, the game freezes. The error message is as follows:
NullReferenceException: Object reference not set to an instance of an object
AC.SceneChanger.ChangeScene (Int32 sceneNumber, Boolean saveRoomData) (at Assets/AdventureCreator/Scripts/Game engine/SceneChanger.cs:30)
ActionScene.Run () (at Assets/AdventureCreator/Scripts/Actions/ActionScene.cs:41)
AC.ActionList+<RunAction>c__Iterator1.MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:148)
UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:128)
AC.<RunAction>c__Iterator1:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:177)
UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:128)
AC.<RunAction>c__Iterator1:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:177)
UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:128)
AC.<RunAction>c__Iterator1:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:177)
UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:128)
AC.<RunAction>c__Iterator1:MoveNext() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:177)
UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
AC.ActionList:ProcessAction(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:128)
AC.ActionList:BeginActionList(Int32) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:106)
AC.ActionList:Interact() (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:72)
RuntimeActionList:Play(MenuActionList, Menu) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:65)
PlayerMenus:CheckClick(Menu, MenuElement, Int32, Int32) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:783)
PlayerMenus:OnGUI() (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:332)
I've noticed that upon restarting the game, the player prefab is NOT found at all in scene 0. It looks like it is not generated at all when restarting the game. Presumably, changing the player's scene is impossible if there is no player prefab present.
Therefore I assume this is a bug. Has anyone else noticed this problem? Thanks!
Comments
Inside that script, try changing line 78 from:
if (!GameObject.FindGameObjectWithTag (Tags.player))
to:
if (GameObject.FindWithTag (Tags.player) == null)