0
Fixed

OnLoad Error: Is this an issue with the way I'm loading my scenes, or with my player?

heysarahshere 4 months ago in Game Creator updated by Marti (Lead Developer) 3 months ago 11

On my main menu, I have a new game option and a load last save option. The new game option just loads a scene, and load last save loads the last save.
When I click one from the main menu, it works fine the first time. But if I go back to the main menu from the game and click either option, I load into the scene with no player and can't move the camera. I get this OnLoad error, but I'm not sure what it means. The player has a player hook and player equipment, and I have game creator set to save scenes. 

Sorry if this is obvious, I'm new to Unity. Thanks for your help!

Unity version:
2018.4.22f1
Game Creator version:
1.1.7
+1
Under review

Thanks for reaching out. Each scene needs to have its own Player and Main Camera in order to work, not sure if that's the case. Regarding the error message... It's simply that we forgot to remove the log from a script inside the Inventory module ^^ I'm opening a ticket to have it removed.

Back to the main topic, when loading a scene/game-save, it doesn't transfer the player and camera objects from one scene to the other. You need to have the player object and cameras in each scene (you can create a prefab to sync all the values).

If that's how you've set up your scene, would you mind recording a small fragment showcasing the issue or sharing some screenshots?

Thank you for the response! So, the On Load message isn't really something to worry about?

it seems that I'm unable to control any player when I load in, or maybe the player never loads at all.

The issue happens when loading a scene from the main menu to the first level scene. In the first level scene, I do have the camera, camera motor, and player set up, although not in a prefab. I made a quick video of that part of the issue.

Should I have the player and camera in the main menu scene too?

It seems to work the first time I load the last save or start a game from the menu, but if I go back to the menu and try either option again, I get the error. the strange thing is that if I die and click load last save from the death screen, it loads fine... but with one catch, the trigger for my weapon does not work. I can equip it, but can't fire. I tried making the trigger part of the weapon prefab, or saving it on my player, or simply in the scene, but it made no difference.

Hmm are you using async loading? When you say the first level doesn't have a camera controller nor a player, you mean the main menu?

I may be throwing an educated guess here, but the lava field and the swamp are different scenes? Could it be that the lava field has a Player and a Camera Controller, but the swamp does not? If that's the case, place a Player also there and the camera controller.


All scenes that will have a Player character in them should have one set in the scene. So even if you have the scenes: Level1 and Level2, both scenes require to have a Player character in them (as well as the camera controller and camera motors if you use them).


If the main menu doesn't have a Player character (so far I see it doesn't) you don't need to set one.


Let me know if this solves the problem or not! If it doesn't, would you mind posting a screenshot of the hierarchy of each scene? To understand the structure of your game.

Hmm are you using async loading? When you say the first level doesn't have a camera controller nor a player, you mean the main menu?


I've tried loading the new scene with async and without, it made no difference. Yes, the main menu, sorry. The first scene is just a canvas with the menu. 

I may be throwing an educated guess here, but the lava field and the swamp are different scenes? Could it be that the lava field has a Player and a Camera Controller, but the swamp does not? If that's the case, place a Player also there and the camera controller.


The lava is just part of the same scene, everything after the main menu is in one scene. It has a player and camera / camera motor. 
It seems that it's actually just loading with the camera inside my player, but I cannot control anything, may be a problem with motor?
The biggest issue beside not being able to move is that upon loading, the weapon no longer fires. It's using projectiles, and I can see that the pool of projectile objects doesn't load. Pressing the trigger button does not load the trajectory either.



Sorry for the late reply. This is quite strange and I can't think of what could be wrong. Not sure if you're willing to do this, but would you mind packing the project (stripping any assets if necessary) and send it to us at support@gamecreator.io? We'll take a look and circle back here.

This will speed things up, since I'm a bit lost where to start looking without the project.

No problem, I appreciate any response at all. I sent the project.

I received your project. I'll take a look as soon as i can. Thanks!

Fixed

Got it. The problem is that when you click the pause menu you set the time scale to 0 to pause the game. Loading a new scene still keeps that time scale to zero.

The solution is very simple. You already have a "On Start" Trigger. Simply add a "Time Scale" Action to 1 as the first action and everything will work out.

PS: Darn this issue was hard to spot :-D I went line by line seeing why it wasn't working until I thought about the time scale.

+1

Seriously?? Thank you so much! You are awesome, I don't think I would've ever figured that out.