Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: nehz on January 20, 2012, 09:58:42 PM
-
How can i make a pet hungry every 6 hours?(real life time)
This includes the next time the player start the game, it will calculate how much time had passed since and for every 6 hours the hunger/food of the pet will will decrease by 10 from the global hunger value pre-set when the egg is hatch.
any help would be much appreciated.
-
searching the site for making custom actions i find some hints on how to access system date..
Animal crossing use this kind of variable and i love how it work.
https://hutonggames.fogbugz.com/default.asp?W351
-
Hi,
Yes, you'll likely need to create some custom actions.
look at the following timespan class:
http://msdn.microsoft.com/en-us/library/system.timespan.hours.aspx (http://msdn.microsoft.com/en-us/library/system.timespan.hours.aspx)
1: store a datetime as frame of reference ( like the last time you have increased his hunger).
2: on start, get the current time and store the difference between the current time and the frame of reference in a timespan class. then find out the number of hours elapsed you can then decrease the value by the number of hours.
if you need help to create the custom actions required for this, tell me and I'll do them.
Bye,
Jean
-
@ Jean:
Can you make the custom actions for me please?
Thank you for your assistance.
-
Such an action might be really useful.
Would it be an OS specific action? Or it`s the same for every platform?
Thanks.
-
Hi,
They would work on any platform ( I am pretty sure of that).
I'll work on some actions for this. Remind me again sometimes next week if nothing come up before... running in all directions at the moment, so might slipped off my mind.
Bye,
Jean
-
Hi,
Here is is:
http://hutonggames.com/playmakerforum/index.php?topic=1047.0 (http://hutonggames.com/playmakerforum/index.php?topic=1047.0)
and I made a unitypackage with a working scene. This is just a proof of concept and more will need to be done for a fully working hunger system, but it deduce per hour, and store in the playerprefs settings so that if you stop and repen it will catch up and starve the right amount since the last time.
Hopefully, that is what you are after. If you need any help or have question, don't hesitate.
Bye,
Jean