playMaker

Author Topic: Save - Load Game - Load on CheckPoint[SOVLED]  (Read 3661 times)

sapigwetao

  • Playmaker Newbie
  • *
  • Posts: 21
Save - Load Game - Load on CheckPoint[SOVLED]
« on: July 20, 2020, 10:37:42 AM »
Hello guys,

im make a 2d Platformer and Shooter game, and i want to add a save data on the game.

SO the player save the game at the "Camp" or Saving Object (By Get Key Down and Save!).
Then when the player died, he can Load the game again at the "Camp".

Also when player quit the game, he can got into the game from the lastest load data.

Im surf on google or forum for this, and use PlayerPref.

And here is the problem, i dont understand how to use PlayerPref. I Tried to use get PlayerPref Int and Float at the "Camp" and use Set PlayerPref INT and Float for the Load on CheckPoint when Die, and Load Game from Main Menu.

And here is the problem.
1. My Data always saving even i havent save it on my Camp.
  [ i tried this when my Character Died when he havent reach the saving point. ]
2. I dont know how to reload the lastest position of the save data ( the lastest level and the lastest position)
3. The Data is Lost when i quit the game.

maybe this is the question, i'll be gratefull if master of Playmakers can answered it for me.

Thank you so much!!! I appreciated it!
« Last Edit: July 23, 2020, 11:30:43 AM by djaydino »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Save - Load Game - Load on CheckPoint
« Reply #1 on: July 20, 2020, 03:10:31 PM »
Hi.
Set PlayerPref is to 'Save' your data
Get PlayerPref is to get the data that you have saved.

So at the "Camp" or Saving Object (By Get Key Down and Save!).
you should use 'Set PlayerPref'.

And to load, use 'Get PlayerPref' and store in a variable.
Now you can use that variable to know where to spawn

sapigwetao

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Save - Load Game - Load on CheckPoint
« Reply #2 on: July 21, 2020, 12:44:53 AM »
Thanks for your Reply, i tried use this things but its still dont work, do i need to use "load level" in a load game?

or maybe that you mean only Get PlayerPref (without float or Int) and Set PlayerPref(without float or int).

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: Save - Load Game - Load on CheckPoint
« Reply #3 on: July 21, 2020, 01:42:24 AM »
Hi,

 the playerpref system only let you save data, it's then up to you to use that in yoru game logic. so if you save the progress of the player, then you save for example in a player pref "Current level", the name of the scene to load. and when the user is opening the game or in a menu that leads to playing the current level, you read that playerpref and load that level.

but you can also save the score for example and you would use that differently in your logic.

 also, don't read and save the playerprefs during yoru game loop, do that in menus or at the end of the level, so for the score for example, keep the scroe in a regular Fsm variable and when the user ends the level, that's when you save the score in the player prefs.


Bye,

 Jean

sapigwetao

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Save - Load Game - Load on CheckPoint
« Reply #4 on: July 21, 2020, 08:21:20 AM »
I have tried but still dont understand.

so at my Camp / saving the data spot, i use Get PlayerPref (float, int, and String).
[@djaydino : i tried to reverse it as like your said. But its not saving the progess lol.]

Get PlayerPref Float is for PlayerHp, EXP, ammo remaining, etc
Get PlayerPref Int is for Player Level etc
try to use Get PlayerPref String is storing my Level name. ( so i can store my level name and can loaded it on the load game data)

but here is something wrong,
1. when i try to use Get Scene Name, it dont store any name on it on the result, so i still dont know how to get the Scene Name.
2. I dont try to save any data, and when im die, go to main menu, and play the game again, its still store the data.
3. How can i load my player to the lastest save Position?( i wonder to use Get Position using Vector)

i got confused lol.

Thanks Jean and Dino

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Save - Load Game - Load on CheckPoint
« Reply #5 on: July 21, 2020, 08:56:35 AM »
Hi.
Can you show some images of your setup (fsms/states/actions)

sapigwetao

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Save - Load Game - Load on CheckPoint
« Reply #6 on: July 21, 2020, 09:58:15 AM »
Here is it,

the Title Camp is for saving point

and i want to use Load on Checkpoint Button to restart the lastest saving point

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Save - Load Game - Load on CheckPoint
« Reply #7 on: July 21, 2020, 10:11:29 AM »
Hi.
Playerprefs are saved in a file on your device.

Playerprefs Get will get the data from that file.

Playerprefs Set will change the data on that file.

So to 'Load' you need to use Playerprefs Get, to store it into the variables.

sapigwetao

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Save - Load Game - Load on CheckPoint
« Reply #8 on: July 21, 2020, 11:09:04 AM »
i think that i just pick a wrong action from the begining.
that i forgot to change the PlayerPref from Get to Set at the camp, and the scene is also save the data.

Its works! thanks Dino!

and i have a little question again,
how do i save my lastest position from the camp?
because when i Load on CheckPoint, or Load a Game, its start from the begining of the level.

is there any tips like i save my lastest position? like save the Vector from Get Position, because i cant place the Vector Position to the any Set Pref or Get Pref.

Thanks

Update : i can use Convert Vector 2d in Set PlayPref String, but i cant get it from Get PlayPref any variables
« Last Edit: July 21, 2020, 11:16:42 AM by sapigwetao »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Save - Load Game - Load on CheckPoint
« Reply #9 on: July 21, 2020, 04:47:43 PM »
Hi.
You can use Get Vector 3 XYZ and Set Vector 3 XYZ this way you can save them as a float.

But if you can afford to purchase Easy Save, you should get this.
I have been using it for years and in all my projects.

sapigwetao

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Save - Load Game - Load on CheckPoint
« Reply #10 on: July 22, 2020, 02:00:44 PM »
Hi, thanks for answering.

here is my progress
1. First i use Get Position Vector from my Saving Point, and give it to Get Vector 3 XYZ, but i cant put it to Set PlayPref Float.
2. So i wonder only to use Get Position X and Y (from my Saving Point Position) and put it to Set PlayerPref Float.
3. in the load to checkpoint, i give the Variable of X and Y to the Get PlayPref Float, and also Set Position with my Player as a Game Object.
4. when my player Die, and i do the "Load on CheckPoint" , my Level, my exp, my ammo etc is still saved. but my player position is still reseting from the begining. and i try to figure it out, its still doesnt work and something weird happen.
When i do "Load on CheckPoint" my player was in the camp position for a millisecond and reseting to the begining of the position.

and thanks for advising me to but Easy Save, but for now i dont have money to buy some assets and its quite expensive. Ill try that when i have a little money to buy thats assets. Thank you

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Save - Load Game - Load on CheckPoint
« Reply #11 on: July 23, 2020, 04:29:57 AM »
Hi.
With Get Vector 3 you should get the x y and z separate as a float, but if 2D x and y can be enough.

for positioning, there must be a set position somewhere else.

When die, do you use load scene?

as loading a scene will reset everything in that scene.

sapigwetao

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Save - Load Game - Load on CheckPoint
« Reply #12 on: July 23, 2020, 09:20:50 AM »
I used Smooth Save for my saving method, it easy and superb!

and i already figure it out how to spawn my character to saving point area, and yes i still use Get Position and Get Vector,

yes i use load scene, and yes its reset, but i can move my character to the saving point rather than load level, its reseting anything, included my character to start spawn point.

anyway thanks for assisting me, thank you so much!!!