Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: FrankDePaul on January 08, 2018, 11:40:34 PM

Title: Advice on plant growth mechanic.
Post by: FrankDePaul on January 08, 2018, 11:40:34 PM
Hello All,
   I have a scene with a crop the player has planted. I know when the scene changes that object will be wiped out. I have a few questions about saving objects to the scene, but also saving the state of the object.

The first question: Is it possible to save the scene when you leave it? With the objects their positions etc.? Or do I need to record everything( variables, positions, rotations) and then load it back in? Seems like a nightmare.

The second question: The state of the plant object is based on time. The game will have a day/night cycle. I assume I should have each plant have a variable keeping track of the time. When the player comes back into the scene, the plant will check the time that has passed and do a calculation to see how old it is. Then update itself with the proper art and animations. I assume this is how it is done.

Any advice on this would be great. Thanks!

Title: Re: Advice on plant growth mechanic.
Post by: verybinary on January 09, 2018, 02:01:06 AM
It might be cleaner to save the plots with whats planted, with rotation(or take out rotation, I don't see this as needed, but please explain your specific use if its actually needed(if you need assistance with it)) and time.
You would have to be careful about the time aspect, if you save a plot as planted at 3pm on 1/1/2017, and they immediately close the game till 1/1/2018, it will still be fully grown(or dead if that is a feature) when they open it back up.
If you want real time, great. If not, you will need to save the variable with how long its been planted(which will only tick away when the program is open)
Title: Re: Advice on plant growth mechanic.
Post by: djaydino on January 09, 2018, 04:26:49 AM
Hi.
I think  xml or json would be useful here.

And also check out easy save on the asset store.
it is one of the best (if not the best) load/save solution with encryption for playmaker.

You can use xml/json with data maker, you can find it on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181)
and you can find tutorials for it on the User Tutorial Wiki (https://hutonggames.fogbugz.com/default.asp?W548) page.

Another option is to use multiple arrays.
But i would suggest using Array Maker (also on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181))

Have arrays for position/time remaining/type/gameobject/other data @ the start you can loop thru them to position them and go thru the other data.
Each Element index represents 1 plant.
While playing you can update the data (time) every second on each plant (use fsm on plant or loop thru plants array to see of there are changes)