Position saver only saves rotation info

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
styx_oarsman
Posts: 5
Joined: Fri Aug 25, 2023 10:34 am

Position saver only saves rotation info

Post by styx_oarsman »

Hi, I have an issue with the Saver that comes with the Dialogue system.

I'm using the Third person starter asset and I'm trying to save the position of the player. I've added the PositionSaver element to the player object (it's called PlayerArmature in this particular asset) but when I save/load the game, only the rotation value is stored, not the actual position. I'm sure that I'm applying this on the correct object because when I try manually changing the position values while in the Play mode (by copy/paste etc) the avatar moves as expected.

I've tried using PositionSaver on other moving objects in my game and it seems to be working correctly (for example, if I save the game after I've opened a door with PositionSaver on it, upon reloading the game the door is open, as expected). So I assume this is specific to the Third Person Starter asset but can't figure it out for the life of me.

Thanks in advance.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Position saver only saves rotation info

Post by Tony Li »

Hi,

I just confirmed that Position Saver correctly restores the Starter Assets' Third Person Controller's position and rotation.

Is it possible that some other script in your project is moving the player after the Position Saver has restored the position?
styx_oarsman
Posts: 5
Joined: Fri Aug 25, 2023 10:34 am

Re: Position saver only saves rotation info

Post by styx_oarsman »

I've tried to replicate the issue in a completely new project, importing nothing but the Third Person Starter Asset and the Dialogue system (plus dependencies). The issue persists... It's quite likely that I'm doing something wrong so I'll try to record the session and post the link here, maybe that'll help clear this up.
styx_oarsman
Posts: 5
Joined: Fri Aug 25, 2023 10:34 am

Re: Position saver only saves rotation info

Post by styx_oarsman »

Ok here's the recording of how I set up the scene, if that helps.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Position saver only saves rotation info

Post by Tony Li »

Hi,

Maybe I missed something with all the changes to the prefabs. Nothing jumped out at me.

Here's an example that works for me:

TestStartAssetsPositionSaver_2023-08-26.unitypackage

It uses a completely unmodified NestedParentArmature_Unpack prefab, so you'll want to try it in a project that has the Dialogue System and an unmodified copy of the Starter Assets package. The player is magenta because I used an existing project that uses the built-in rendering pipeline instead of URP, but that shouldn't matter. It just affects the rendering.

styx_oarsman
Posts: 5
Joined: Fri Aug 25, 2023 10:34 am

Re: Position saver only saves rotation info

Post by styx_oarsman »

Alright, I took a look at your scene and I think I have the answer! Setting the value of Save system -> Frames To Wait Before Apply Data to 1 seems to do the trick. Mine was set to 0. Not quite sure why this is the case but it seems to work.

Thanks for the help, I really appreciate it.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Position saver only saves rotation info

Post by Tony Li »

The starter assets may initialize its position in a Start() method, which runs right before the first frame. By waiting 1 frame, the Position Saver gives the starter asset time to initialize itself first before moving the player. Otherwise the initialization might move the player back to its original position.
styx_oarsman
Posts: 5
Joined: Fri Aug 25, 2023 10:34 am

Re: Position saver only saves rotation info

Post by styx_oarsman »

Makes sense, thanks.
Post Reply