0
Under review

Not saving player position

Tathunder 4 months ago in Game Creator updated by Marti (Lead Developer) 1 month ago 20

Hi, so I have got saving and loading working. I have turned saving on in preferences and all the player components have save checked.

Everything is working except that the player's position is not saving.

On load game the players position changes to the default player location.

How can I save the player's position also?

Many thanks,

Unity version:
1.1.8
Game Creator version:
2018.4.19f1
Under review

I just tested this and works fine on our end. The player's position and rotation are saved and correctly restored when using the "Load Game" action.

Can you make sure you're not using a Teleport action somewhere? Also, is your scene brand new with only this functionality in place? This may help you narrow down the issue.

Thankyou, Marti.

I am sure I am not using a teleport action. I tested with a new scene and the players position has saved correctly. I tested with my prefab ingame menu, It worked fine saving, going to the main menu and then loading. However in a playtest if I start a newgame on my original startgame scene and then try to load the game, saved on the new scene, then the player's position has reverted to default again(not saved correctly). 

So, I then went to my start new game button on my main menu scene. I changed the load scene to the new scene and it is still working perfectly as you predicted. I'm presuming that my problem must be on my original scene or scenes.

Any idea what I have done wrong?


I tested with a new gc character on my original scene, and the saving/loading is working. I suppose the problem must be on my player. I will keep investigating and will try rebuilding my player.

Ok, the problem occurs as soon as I change my model on the player. My model is a simple low poly truck I made, that is not currently rigged.

I have tried it set as both generic and humanoid models.

I also have another question already posted on this forum, regarding saving, where I am having certain things persist on a new game when I would prefer they didn't. I don't know if they are related or not.

If I change the player's model back to default. It fixes my saving woes... I really like my truck however. Does my model need a skeleton to save correctly? 

I tried rigging it with a single bone. Still not saving correctly.

Not sure I understand the issue. So changing the 3D model of the Player makes the entire Player not save? When you mean save the character, you mean the current model? Or the position?

Position should save regardless of the model used (in fact, these systems have little to do with each other, so they shouldn't conflict). On the other hand, Unity can't serialize game objects, so it's not possible to save current 3D model used changed at runtime.

Hi,

when my character has my generic model, when I load a saved game, the position is not as it should be.

If I change the model on the character back to default (in the editor before running the scene), and then try to save and load the game, it saves the position properly.

Just tested this on a new project, with a different generic model(low poly rigged mech), and I still have the same issue of the position not loading correctly on a save game.

I have tested this and seems to work fine on our end. Maybe you have trailing player prefs that are messing with the Save/Load system.

Can you try going to Edit -> Clear Playerprefs and test again? This will remove any previously saved data. It's also a good practice to remove it from time to time.

I have tried Clearing Playerprefs on two different projects and my problem is still happening on both. 

Just made a new scene. Added a plane and an object for reference. Added triggers for load and save. Added a GC player and a camera motor.

Start Play. Works fine, the loading and saving has no issue.

Stopped play. Changed my player model to a generic model. Play. Loading and saving has stopped working again.

Stopped play. Cleared Playerprefs. Click Play. Loading still not working.

Changed the player model back to default. I made a trigger to change my the model to my model when I press space.

Tested it. I move away from the start, change my model and then save the game. When I load the game the position has loaded correctly but the model has reverted to the player model.

"Hhmmm" I think... can I work around this? Changed my change player model trigger to on start. Now the player model is a mech from the start but the position has stopped working...

I added a 0 wait action before changing the model. And it is changing to my model and loading the player position to my liking except that the GC default player model flashes briefly when I start the game.

I should be able to work around this with a splash screen or something.

So, now I have been able to work around the issue but I am still a bit bothered why I am having this issue and no one else is.

I have another issue with GC and saving/loading games/profiles (when starting a new game attributes/stats and inventory have persisted despite changing to a blank profile) that I have detailed in another post. I wonder if the two problems are connected. I have been able to work around those problems too however with lot's and lot's of Onstart triggers resetting things.


Thank you for all the time you have spent trying to help me sort this. Any further ideas on how I can better fix this?

I'm opening a ticket to have a look. As a wild guess, are you using Navmesh? If so, could you try deactivating it and see if that works now? If you are not using it, try activating it. Just a wild guess before I get started on it.

Hi,

I just re-tested with Navmesh enabled and disabled on the player and it has not made a difference with the save/load.

I have also tried re-installing unity and VS. I have tried changing my language in VS to English (just in case, haha). Did not help.

I'll provide some specs just in case it is helpful.

I am currently working on a windows tablet as my desktop is back in my country of residence (I have been a refugee in the UK for the past 7 months because of Covid). Hopefully when I make it back home GC will work flawlessly on my desktop - but that may take a while...).

The OS on my tablet is a Chinese language version of windows 10.

Intel M3-7Y30 @ 1.00Ghz

Has 8GB RAM

It uses Integrated graphics but is doing ok.

It can run Mount and Blade Bannerlord and many other higher spec games, so it is probably is not a problem.

Many thanks,

I finally made it home and tested it on my desktop PC and I am still experiencing the same problems. Are you sure you can't reproduce the problem of a non humanoid (generic) player model not loading the saved position correctly?

Yeah, everything seems to be working nominally. The player's position is saved when saving the game and loading it back restores the player's position.

Make sure the Player has, under Advanced Settings, the "Save" checkbox enabled. Humanoid or non-humanoid characters shouldn't really influence in saving the position.

trucktry2B.blend
trucktry2B.blend.meta

The save checkbox is enabled. I have tested both with and without and the position is not loading. If I use the Game creator default player model, it then works as it should. I have tested on two different PC's. Set it up from scratch on a new scene and it still is not working properly. My "generic" non humanoid models are breaking it somehow.

I just made a new project with the 2019 LTS of unity. Downloaded GC 1.1.9. Made a new scene, with a plane, and a player. made triggers to save and load the game. Tested it with the default player. No problems.

Changed the player model to my truck model. The location is still not loading properly. 

I can't understand how I can have the same problem on two different machines and no one else is experiencing it.

I would really like to fix this and understand why it is happening.


The save check box is checked on the player's advanced parameters. I have tested with and without the player able to use the navmesh, with and without it baked. I have tried clearing the player prefs many times.

Other modules I have loaded are: shooter, inventory, stats and behavior.

Hi Marti,

My best workaround so far is to not remove the default model, but to instead turn off the mesh renderer and then manually add my truck model to the player. This makes the loading work as it should. 

What is the best way to now change a player model in-game without breaking the saving/loading? Will there be any other unexpected consequences if I set up my player model this way?

Not that I can think of. You can call an "On Start" Trigger and use the "Change Model" action to swap the player's default model for your truck.

One thing that I've experienced is that the latest Unity versions have a broken Playables API graph. You mention that you're using Unity 2019.4, so it shouldn't really affect you, but just in case you tried this in 2020.2.

To be honest, this issue has me very intrigued, as a 3D model is basically a dummy game object without any logic behind it. It shouldn't really affect the player's save position.