playMaker

Author Topic: how to make a timer and a basic turn system  (Read 5850 times)

jellyam

  • Playmaker Newbie
  • *
  • Posts: 19
how to make a timer and a basic turn system
« on: October 08, 2017, 12:59:02 PM »
hey guys, I've mostly been lurking here but I recently made some playmaker tutorials you guys might be interested in

simple turn system
https://www.youtube.com/watch?v=rzpDZsDdA_U

timer
https://www.youtube.com/watch?v=8Pt2JE5WGpA

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: how to make a timer and a basic turn system
« Reply #1 on: October 09, 2017, 05:47:50 AM »
Hi, good start with the tutorials. :)

The turn mechanic could be improved a little, and work without the every frame check. You can do this using global events, and send event.

Think of this as a chess clock which gives control to one player. The player does their thing, then hits the Clock to say "I'm done" and the Clock then "knows" what to do next. That is: give control to the next player. Using a Clock or Manager as a third party is a bit more robust, because then you can separate the taking turns rules from whatever is supposed to happen within a given turn. In a more complicated game, it can count up the int which stand for any number of players, for example. It can skip turns, or change the order etc. Thus, it's better to keep this mechanic separate in more advanced games.

If you really only have two players in a simpler game, you don't strictly need the Clock, because you then can start both players and let them run into an Idle / Awake state. One of the two continues to whatever they do in their turn, while the other is stuck in the Idle, going to Sleep. When the active player is done, it goes to it's Sleep state, but before it Send Event over to the other player to wake them up , to start chain of events. Now the other player's FSM runs becomes active player and does whatever it does, until done, go sleep but before Send Event over again to wake up the other player, and so on.

I built an example on the quick. Player Blue's job is to press the space bar, and Player Red's job is to press the tab, taking turns. You're correct that using Input Manager is always a good idea, but for debugging and testing I use the keys.

jellyam

  • Playmaker Newbie
  • *
  • Posts: 19
Re: how to make a timer and a basic turn system
« Reply #2 on: December 03, 2017, 08:46:33 PM »
i can't believe it took me this long to see this post! I took a look at the unitypackage and I'm going to share with my youtube audience since its better than what i did in the tutorial. =) and thank you


Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: how to make a timer and a basic turn system
« Reply #3 on: December 06, 2017, 06:35:47 PM »
Glad it's useful. Go ahead, and use this as you see fit. :)