Forum rules - please read before posting.

Loading a Save doesn't modify y-axis of the player

I have a NavMesh that covers two floors of a building and the staircase between them.
To make it less awkward to explore, at any time one sub-mesh is active consisting of the room the player is in and any adjoining rooms for which the door is open.
When I save the scene and then load it again the x and z coordinates of the player are restored but the y axis remains as it was before the save. In other words the save/load doesn't modify the floor that the player is on.
There is one exception I've noticed; if the player is standing on the stairs, that is restored.
Maybe the player can't pass through the higher floor of the NavMesh when he is moved during the reload?
If you want further clarification please ask. Any pointers or solutions are welcome.   

Comments

  • The save system does indeed save the player's position in all three axes, and restores them when loaded.  It could be that the floor colliders are so thin that the player is passing through them to the floor below.  Check how their thickness compares with that of the collider on the stairs - that could be the key.
  • The floor colliders were indeed a bit thin. I have thickened them but the problem is still there.
    It's not that the player always appears on the ground floor, but on the same floor he was on before the load. Whether it is the ground floor or the first floor, that is the floor he will still be on after the load although his x and z coordinates will be correct.
    I think it might have something to do with the NavMesh, or with the numerous smaller navmeshes based on his current position. I have to save and load these in the variable change and the load cutscenes as I can't get them to work properly using the Remember class.
    I'm sure your default save and load are fine; I'm doing something wrong, I don't think it's with the colliders but I can't put my finger on what it is. 
  • You don't want to attach any Remember script to your NavMeshes: just the ConstantID component.  This will create a reference that allows the current NavMesh to be saved.  Remember scripts are only needed when anything about the object your saving changes.
  • Thanks Chris. I've removed the Remember Scripts from the navmeshes but kept the varchange and load cutscenes based on the KickStarter code for navmesh initialization.

    The problem I am having isn't limited to save and load; 
    If I place the player model on the first floor using the Scene editor with the PlayerStart on the ground floor and then start the game - the player appears on the first floor above the Player start, not on the ground floor. 
    Also, please disregard what I said about his position being correct on the stairs. I don't think I can have tested that properly.
  • If I place the player model on the first floor using the Scene editor
    with the PlayerStart on the ground floor and then start the game - the
    player appears on the first floor above the Player start, not on the
    ground floor.

    Do the X and Z positions match?  ie. only the Y is affected in this specific example?
  • Yes. I place the player on different x & z coordinates before starting and they match the player start coordinates when I start the game, but the y axis only changes to the upper floor, not the lower floor where the player start is.
  • I think reached the limit in terms of what I can advise without seeing it for myself.  If you can, please make a UnityPackage of the scene (without any of AC's files, i.e. just the minimum needed for me to see the problem), and PM it to me.
  • Chris got back to me and told me to remove the NavMeshAgent from my Player. That solved the problem with the saving and loading. Then I payed closer attention to the 3D tutorial and was able to get the Player up and down the stairs with collision cubes, pointing and clicking. So: Problem solved. 
    Many thanks Chris!
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.