playMaker

Author Topic: Multiple Lap Timer[SOLVED]  (Read 4687 times)

455224

  • Playmaker Newbie
  • *
  • Posts: 7
Multiple Lap Timer[SOLVED]
« on: January 16, 2015, 01:39:18 AM »
Hi All,
I'm very new to both unity and playmaker but have been having fun and made some decent progress on my first small game, an arcade racer. The problem I am having is that I want to make a 'Time Attack' mode where everyone (the player and the AI) have their lap times recorded, all whilst on the same track...

My first, and pretty much only, idea for this is to have multiple triggers, each with different tags, but then I'm confused as to how I'd get the seperate delta T for everyone?!? I guess my question is, is this do-able or is this more big boy AAA type territory? I'm also thinking of adding in permanent upgrades, which should also be really interesting to try and work out how to do! haha

Cheers!

Edit:Also, having a think, the 'Time in current state' might also work, but again doesnt seem very elegant... still fully open to any better ideas!
« Last Edit: February 19, 2015, 06:42:40 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Multiple Lap Timer
« Reply #1 on: January 16, 2015, 05:07:05 AM »
Hi,

don't hardcode each player, you can get away with something a lot more object oriented and nice.

you will need a trigger as the finish line, tagged "Finish Line", and a trigger/collider on each player.

then each player will have an fsm that will watch for this finish line trigger and filter by tag, so that that fsm only responds to this finish line trigger.

 then, yes, you are right, use time ( a different between the time recorded when started/crossing line and the time when crossed the line).

To keep track of each laps, you'll need a way to store this in lists, and for this, you'll need ArrayMaker

So, yes, this is not the most basic behavior to implement, but if you are patient and study the various samples on dealing with time, triggers and arrayMaker, you'll get it done.

 Keep us updated on your progress :)


 Bye,

 Jean

455224

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Multiple Lap Timer
« Reply #2 on: January 16, 2015, 05:18:54 PM »
Hi Jean,

Thanks for the quick response, can't wait to implement it in game!

Edit:
I've just fired up Arraymaker and can't find anthying refering to multiple rows ie. no (x,y) index, only (x,1). Is this correct or am I missing something?

Thanks,
Ross
« Last Edit: January 17, 2015, 10:52:49 AM by 455224 »

455224

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Multiple Lap Timer
« Reply #3 on: January 17, 2015, 11:03:23 AM »
Sorry to be a pain, but now I've coded the lap timer (works great, massive thanks for your help!) when I try and format the result to "x.xxx" (previously, unformatted it was "x.xxxxxx*e^y" it doesn't display the result any more? I have downlaoaded and installed Maddox's script for changing formats and doesnt seem to help?

Any ideas, from anyone, would be greatly appreciated!

Initial State:
http://pasteboard.co/qAPQ7Tr.png

State 3 Triggered (one lap complete):
http://pasteboard.co/qASgBLs.png

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Multiple Lap Timer
« Reply #4 on: January 19, 2015, 12:48:09 AM »
Hi,

 the format string would be '0.000' or 'n3'

http://stackoverflow.com/questions/6356351/formatting-a-float-to-2-decimal-places

then it works.

 Bye

 Jean

455224

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Multiple Lap Timer
« Reply #5 on: January 19, 2015, 01:15:03 PM »
Hi Jean,
I tried both and it still displays 0.000, instead of the actual time, in the GUI? When i remove any format string ie." " it works but to 6dp. Do you think it is a bug?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Multiple Lap Timer
« Reply #6 on: January 19, 2015, 02:00:55 PM »
Hi,

You should use the action "Convert float to string" action. Have you tried with this one?

also, in this kind of cases, you should always test on an empty scene, one fsm, one action and the minimal setup required to test that action, when that works, implement it in your project.

 Bye,

 Jean

455224

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Multiple Lap Timer
« Reply #7 on: January 19, 2015, 03:16:58 PM »
Thats exactly the action I'm using, I've got next to nothing in my scene, and only 2 fsm's but I'll strip it back as much as I can and retest it. Not hoping for much as I have tried all the obvious options with no luck, but we'll see.

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Multiple Lap Timer
« Reply #8 on: January 20, 2015, 01:37:18 AM »
Hi,

 It must be something silly, as always... :P

 I have attached the sample I used so that you can see it works properly.

 Bye,

 Jean

455224

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Multiple Lap Timer
« Reply #9 on: January 21, 2015, 05:18:36 PM »
It must be something silly, as always... :P

Indeed it was! I needed to add a trigger event (with no target) to the start of the FSM and change the end trigger to an exit collider. Thanks ever so much for your help, hopefully this thread will be of use to someone else too!