playMaker

Author Topic: Storing "Get Position"/"Get Rotation" not working properly on level restart  (Read 776 times)

KnightOfAudio

  • Playmaker Newbie
  • *
  • Posts: 3
Hello everyone,
I'm using Playmaker extensively in my first game, which only has one actual level, and I'm using Smooth Save to create checkpoints at certain points.

I'm using the Standard Assets First Person Controller, "Player", parented to an empty, "Player Parent", so that I can control its rotation on load (An admittedly minor polish, but I want to do the best I can). My method is as such:

Player picks up an item, which activates an empty GameObject that has the following FSM:
*Get Position and Rotation of Player and store as LoadPos/LoadRot in world space*
*Set Global Bool "Checkpoint" to true*
*Save Data Pool (Smooth Save)*

After the player dies, and the level restarts, an FSM attached to "Player" runs the following:
*Load Data Pool (Smooth Save)*
*Set Position and Rotation of "Player Parent" to LoadPos/LoadRot in world space*

Sometimes it works perfectly, other times my character is translated forward several units until I provide movement input, at which point it snaps back to the correct space.

I can run it in the editor a few times and get scenario A, then one more time and get scenario B, performing the same actions in game each time. Making a build is hit and miss as well, the issue sometimes pops up, sometimes doesn't.

Functionally, it's doing what I ask, aside from the camera glitch (the camera is of course parented to "Player"), but I'd rather a player not get outside the level, even if they can fix it just by moving around.

I'd much prefer to release a game with as few glitches as possible, so if anyone has any insight on how to fix this, it'd be greatly appreciated. :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Hi.
There is probably something wrong in your logic.

Try some debugging with breakpoint.

Probably something is interfering, are controls activated right @start?

then you might need to set it so that it does not do that right at the start, only after loading and setting location.

it hard to know what is causing the issue without looking at the fsms.

here is a video about debugging :


KnightOfAudio

  • Playmaker Newbie
  • *
  • Posts: 3
Thanks djaydino,
I did discover that the camera is actually what's translating for some reason. When the scene reloads, the camera is 6 units on the Z-axis from its parent (the player), and movement snaps it back to it's origin.

I watched the video, but I'm a little unsure where to put my breakpoints. Perhaps on any set position that references LoadPos?

I could brute force it and force the Z position of the camera to 0 on start, but I'd prefer to learn proper methodology. I'll continue to debug and let you know if I find anything out.

KnightOfAudio

  • Playmaker Newbie
  • *
  • Posts: 3
I still haven't figured out the camera problem, but I switched from Save/Load Data Pool to Copy Globals to Pool/Copy Pool to Globals, since I noticed the former were actually throwing out errors. They were working within an instance of the game, but the Copy actions properly save the data from instance to instance.

The other thing this has done is allow me to load the offending situation each time, since the save properly stores the data, and try fixes on it. The camera always seems to glitch 6.5 units away on the Z-axis.

I've tried implementing a wait timer before moving position to LoadPos, but that doesn't snap the camera back like simple movement does.

I also tried disabling the first person controller component until after the loading process, but that also did nothing.

Out of 4 Set Position actions I have, 3 are on the player and 1 is on an elevator, so I know nothing is touching the camera's position, which makes this all the more bizarre. So far the only thing that fixes the issue is resetting the camera's local Z to 0 via Set Position. It's a bandage, but what caused the injury?

One big thing I don't understand is that if the camera is a child of the player, shouldn't the camera stay 6.5 units away when the player moves? I don't have anything referring directly to the camera's position (there's only a handful of "Set Position actions called in the whole scene).

If there's more info I can provide, please let me know. If I'm just missing a piece of logic here or there and end up not figuring it out, at least I know a fix for it.