playMaker

Author Topic: Advice on save/load  (Read 2402 times)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4120
    • View Profile
    • jinxtergames
Re: Advice on save/load
« Reply #15 on: May 05, 2018, 03:09:42 PM »
Hi.
How many children will there be maximum on an object and do they also have different positions/rotations?

Are the blocks with children making different forms (like 2x2 block, 2x4 block and so on)
if so you could build then and make prefabs from that, in that way it will be easier to setup (and probably faster loading)


Naming would not really make it easier to save/load nor make it harder (you would need another array to save the names or when using datamaker, add it in the list) on a little more work.

if you can show a video or post some images or post the scene would be helpful
You can also pm them if you do not want to do this public.

richardh

  • Junior Playmaker
  • **
  • Posts: 97
    • View Profile
Re: Advice on save/load
« Reply #16 on: May 05, 2018, 04:33:09 PM »
@djaydino
The children that are added to the blocks are what I call phantom cubes - they are identical sized cubes to the parent cube and are literally surrounding the parant. So I have 5 phantom cubes imme3diatley surrounding their parent on all sides apart from the bottom (bottom phantom is not needed). The job of the phantoms is to be hit by a raycast from the VR controller which will get the position of whatever phantom it hits. This phantom position (phantom is invisible in the scene - mesh renderer off) will be used for the placing of the next cube. The player will pick up (copy) another cube and point his controller toward the already placed cubes. when the raycast hits a phantom it will activate (mesh renderer on) and the player will decide if he wants to place his next cube there. Controller trigger press will add the next cube to the phantom's position.... and so on.

So there are 5 children given to the new cubes (copy cubes) which act as position placements for subsequent cubes. Their position is always immediately next to the parent and there is no need for these children to move position or rotate once they are added to the scene.
If the parent cube is deleted by the player then so are the children. if the parent cube is picked up and replaced by the player then the children are destroyed (on pickup) and created again (on placement). If the parent cube is rotated (left/right) or spun (clockwise/anticlockwise) the children remain static (no need for them to move or rotate).
The children are not visible in the scene (mesh renderer off) but are used purely as location positions for more cubes.

I suppose that, on save, the phantoms (children) could be destroyed so only the original cube (name, pos & rot) are saved. And then created once the game loads again?
Would that make things easier?


Hope I've explained that okay. I can post a short vid if it helps.
ta

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4120
    • View Profile
    • jinxtergames
Re: Advice on save/load
« Reply #17 on: May 06, 2018, 01:54:27 PM »
Hi,
I think i understand.

Destroying objects is expensive and leaves garbage, so i would consider to change this.

Instead you can have these phantom boxes preset on each side and activate/deactivate them

Or another way could be to place the triggers on the edge of each side.
then use an indicator, here you can see what i did, i will try to make a video before Wednesday.

https://i.imgur.com/8t7nYe3.gif

richardh

  • Junior Playmaker
  • **
  • Posts: 97
    • View Profile
Re: Advice on save/load
« Reply #18 on: May 06, 2018, 04:16:47 PM »
Not sure I follow that video. I'll rewatch it and see what you're doing. The triggers you're using are sort of like what my phantoms are doing. How would you place the next cube(s) exactly in the correct position using this method?
I admit that my setup for new cube placement (using phantoms) is not that elegant and will have to be changed but the real issue is how to save and load those already placed cubes in the scene. Once I nail that I can redesign my 'phantom' placement method with something that doesn't involve destroying. Although, theoretically, destroying objects should not play a huge part in the game.
thanks for the help :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4120
    • View Profile
    • jinxtergames
Re: Advice on save/load
« Reply #19 on: May 07, 2018, 02:15:06 PM »
Hi.
By designing them this way you would only need a single prefab, and then it is easier to save/load the positions from those prefabs.

i made a working system now (with multiple colors)with save and load in it.

To position the blocks i parent the 'indicator to the select block/side and for each side the position is set locally from the selected block.

I will try to make a tutorial video in the next days, here is a preview on what i made :


richardh

  • Junior Playmaker
  • **
  • Posts: 97
    • View Profile
Re: Advice on save/load
« Reply #20 on: May 07, 2018, 02:26:08 PM »
What you have done there, in probably half an hour, took me 2 weeks! feel very inadequate!
Yes, please, make a tutorial if you can. I really need help on save and load.

thanks for your help and time, sir!

Edit/Update:
Here is a link to a quick and dirty YouTube vid of the project prototype I have created so far:
https://www.youtube.com/watch?v=mGIboQZC5-I&t=19s
« Last Edit: May 08, 2018, 05:16:08 AM by richardh »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4120
    • View Profile
    • jinxtergames
Re: Advice on save/load
« Reply #21 on: May 08, 2018, 01:11:34 PM »
Hi.

Ah thx for the video.

For this i would use pooling and store the object names or pool names in a addition array and not an array for each object.

i will adjust my sample and try to make a video tomorrow.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4120
    • View Profile
    • jinxtergames
Re: Advice on save/load
« Reply #22 on: May 10, 2018, 04:06:41 PM »
Hi.
Sorry i did not have time to make a propper tutorial, but i did record a video explaining what i did.


richardh

  • Junior Playmaker
  • **
  • Posts: 97
    • View Profile
Re: Advice on save/load
« Reply #23 on: May 11, 2018, 03:23:34 AM »
That is excellent @djaydino
I will watch that vid and try to apply it to my own project.

Is there any chance of downloading the scene you created in the vid? So I can dissect it at my leisure as I watch and learn the video?

I will put a nice donation in your donation box ;)




djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4120
    • View Profile
    • jinxtergames
Re: Advice on save/load
« Reply #24 on: May 18, 2018, 02:16:07 AM »
Hi.
Did you get it to work?

richardh

  • Junior Playmaker
  • **
  • Posts: 97
    • View Profile
Re: Advice on save/load
« Reply #25 on: May 19, 2018, 03:57:29 AM »
Easy Save is amazing.

No, I've not had a chance to properly delve yet. Had a look but I will need to really take time to work out what you've done.