playMaker

Author Topic: [SOLVED] How to make a timer count to 60 rather than 100  (Read 6150 times)

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • Rage Quit Games - Coming Soon
[SOLVED] How to make a timer count to 60 rather than 100
« on: June 04, 2012, 01:07:25 PM »
I've noticed when using float values to make a timer that it counts to 100 then adds a 1 to the timer, if you look in the attached picture you'll see how i'm formatting it with the convert.

How would i go about making it count to 60 to add the 1 rather than 100?
« Last Edit: June 06, 2012, 05:13:52 PM by Alex Chouls »

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: How to make a timer count to 60 rather than 100
« Reply #1 on: June 04, 2012, 01:33:38 PM »
do it manually. add 1 to seconds(int) , check if int = 60, then wait 1 sec if seconds is not 60 and then send an event to a state which converts int to string and then builds a string from seconds and minutes. If it is 60, send another event to another state. Have that state add 1 to minutes(int) and set seconds to 0. Then return to the first state .

Quite simple , really, just hard to explain since it involves multiple states :D
Best,
Sven

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • Rage Quit Games - Coming Soon
Re: How to make a timer count to 60 rather than 100
« Reply #2 on: June 04, 2012, 05:14:52 PM »
do it manually. add 1 to seconds(int) , check if int = 60, then wait 1 sec if seconds is not 60 and then send an event to a state which converts int to string and then builds a string from seconds and minutes. If it is 60, send another event to another state. Have that state add 1 to minutes(int) and set seconds to 0. Then return to the first state .

Quite simple , really, just hard to explain since it involves multiple states :D

Thanks for the brief on how it's done but i still don't know where to start.

Time is one of the things that gives me the biggest headache, for some reason the way things are worked often makes no sense to me at first.

Any further advice?

EDIT - After an evening away from thinking about the problem and some sleep i think i should be able to figure things out, thanks again for the brief :)
« Last Edit: June 05, 2012, 01:10:33 PM by MrMitch »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to make a timer count to 60 rather than 100
« Reply #3 on: June 06, 2012, 03:20:17 AM »
Hi,

 have you found the solution? let me know if not, I'll do a working example ( don't hesitate to share a package if you feel that could help)

 Bye,

 Jean

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • Rage Quit Games - Coming Soon
Re: How to make a timer count to 60 rather than 100
« Reply #4 on: June 06, 2012, 01:25:37 PM »
No i've not found the solution as of yet, a working example would be greatly appreciated Jean :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to make a timer count to 60 rather than 100
« Reply #5 on: June 06, 2012, 03:06:17 PM »
Hi,

 Ok, here we go. your misunderstanding of the situation is the following:

 a float is treated as a base 100 as default, because this is the way we count. If you want to think as a float representing the number of seconds of a time span, then you need to use specific function ( hours are base 24, minutes and seconds are base 60. While you can compute that yourself with simply math trick, c# has it all figured out for you already.

 So I made an action that wrap all this:

http://hutonggames.com/playmakerforum/index.php?topic=1711.0

In your case, the format you want to set is the following:

{1:D1}:{2:D2}:{3:D2}

and that will really show a time as we understand it ( seconds counting to 60 to increment 1 minute)

If you have difficulty with this formating concept, visit and msdn help ( in the thread above)

Bye,

 Jean

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • Rage Quit Games - Coming Soon
Re: How to make a timer count to 60 rather than 100
« Reply #6 on: June 06, 2012, 03:39:48 PM »
Thank you very much Jean, it works perfectly :)

This should be really helpful for others as well.

Also thanks for explaining how each value is looked at within unity :)