playMaker

Author Topic: Save/Load player position  (Read 1455 times)

Seiryu33

  • Full Member
  • ***
  • Posts: 135
Save/Load player position
« on: October 11, 2022, 06:39:15 PM »
So this has been a head-scratcher for the last little bit, and it's a bit difficult to explain my goal. I'm trying to save/load the player position at specific points; at load of new scenes, at save-points etc. Attached is the code i'm using, which saves/loads the last saved scene fine but unfortunately can only save/load active objects in the scene, not objects in other scenes, which in this case is the Player object. It will save/load as long as the player object is actually in the scene but not from a load screen because there's no active object to save/load the position of. The only solution i can think of would be to set the player object as a game object with a global variable but I can't select the variable it's attached to with the actions i'm using. What am I missing in this code?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Save/Load player position
« Reply #1 on: October 12, 2022, 04:15:05 AM »

HI

so for each scene you are loading the player?
maybe use player with a don't destroy on load and set player in a global variable.

otherewise on your custom action use a FsmGameObject as variable to use playmaker variables.
also Start() should not be used in actions.
you can move in onenter.

best is to have a look to existing actions to understand how the fsm variables work

Seiryu33

  • Full Member
  • ***
  • Posts: 135
Re: Save/Load player position
« Reply #2 on: October 12, 2022, 06:51:42 AM »
Also save/load the player at Save-points. Using FsmGameObject was my first thought but the actions came back with errors. I'll see if I can tweak it.
« Last Edit: October 12, 2022, 06:58:13 AM by Seiryu33 »