playMaker

Author Topic: [SOLVED]How to save object position between scenes?  (Read 2577 times)

spicyasian128

  • Playmaker Newbie
  • *
  • Posts: 18
[SOLVED]How to save object position between scenes?
« on: March 02, 2018, 02:27:55 PM »
I've been tying to get a hang of playmaker over the last few days that I've had it, and I'm starting to get a pretty good handle on things, but the one issue I still havent found a solution to is how to maintain scene structure between transitions. Right now my game is set up so that if the player obj collides with an enemy, it triggers a new level to load that just features some really basic turn based combat, but when that scene returns to the original, the whole thing resets. I had initially solved that by just making a brand new scene all together, but the issue then was that the player object would always load in the same position regardless of where the enemy collided with them, and now it's also starting to take up way more disc space than is optimal. What I'm wondering is how I would go about actually saving that player position, I considered setting the whole stage as an additive but then i figured that i'd just end up with two scenes overlapping each other. Is there a way for me to save the player's position on exit, and then reload the scene in that same position?
« Last Edit: March 03, 2018, 02:08:26 PM by spicyasian128 »

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: How to save object position between scenes?
« Reply #1 on: March 02, 2018, 02:48:58 PM »
I don't know how your game is exactly organized, buy can you get position when you hit the enemy, and then set position when you get back?
Available for Playmaker work

spicyasian128

  • Playmaker Newbie
  • *
  • Posts: 18
Re: How to save object position between scenes?
« Reply #2 on: March 02, 2018, 03:31:23 PM »
I tried that, but all it seemed to do was set my player position at 0,0,0 when i first load the level. Though I'm assuming that I did something wrong.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: How to save object position between scenes?
« Reply #3 on: March 02, 2018, 04:09:55 PM »
What do you mean by when you first load the level? If you walk around, you change the position, when you save it it should be anything but 0,0,0.
Available for Playmaker work

spicyasian128

  • Playmaker Newbie
  • *
  • Posts: 18
Re: How to save object position between scenes?
« Reply #4 on: March 02, 2018, 04:22:31 PM »
0,0,0 isnt the location the level starts at, rather it happens to be in a wall in my level, I have it set up in my level manager that the first thing to happen is the position being set, and then in the same event that triggers the transition, it gets the position of my player obj, but as soon as i start the initial level, my players position is changed to 0,0,0. and the same thing happens when i reload the level from my battle state, so I cant figure out if it's actually working or not, because it keeps setting my pos at 0

spicyasian128

  • Playmaker Newbie
  • *
  • Posts: 18
Re: How to save object position between scenes?
« Reply #5 on: March 03, 2018, 02:07:58 PM »
So I never actually figured out how to save player pos between scenes, but I did find a good workaround that might help anyone else with this problem. Instead of having my battle scene and main level be separate scenes, I kept them both in the same scene, but put the contents of each into an empty, which I controlled from the outside with a level manager that would activate the main level on startup, and deactivate the battle until I collided with an enemy obj, at which point it would do the reverse, and delete the enemy in a state before returning to the main level. It isnt the solution I wanted but it saved a ton of space for me, so maybe someone with the same problem will be able to use this for reference.

shinodan

  • Full Member
  • ***
  • Posts: 180
    • Shinozone
Re: [SOLVED]How to save object position between scenes?
« Reply #6 on: March 08, 2018, 05:21:13 PM »
Hi, i didnt finish reading this post but wanted to pitch in.

Why not just get position, convert it to a string and store it in player prefrences? Then when you load the scene get that playerprefs string, convert it back to vector3 and set position?

I think the vector3 to string action is on the ecosystem if not already included in playmaker as standard?

MattyWS

  • Junior Playmaker
  • **
  • Posts: 90
Re: [SOLVED]How to save object position between scenes?
« Reply #7 on: March 09, 2018, 05:26:13 AM »
Maybe bad practice but doesn't global variables carry across scenes?