playMaker

Author Topic: Help needed with RTS like Unit Selection and Movement. [SOLVED]  (Read 5998 times)

matias

  • Playmaker Newbie
  • *
  • Posts: 2
Help needed with RTS like Unit Selection and Movement. [SOLVED]
« on: November 04, 2011, 08:41:00 AM »
Hello everyone, about a month ago I'm with couple of friends bot a Playmaker and we are trying to create a little 2D strategy game for IOS with mechanics similar to Battleheart from Mika mobile or Trenches. So I need to create characters selection and movement functionality.
I was looking through forums and a lot of people sugesting to use MousePick action for that kind of stuff, it works for movement but It seems that action only move preset object and dosent have any functionality to select diffrent objects(characters). Or did I missed something? :)
« Last Edit: November 30, 2011, 10:39:38 PM by alexchouls »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4002
  • Official Playmaker Support
    • LinkedIn
Re: Help needed with RTS like Unit Selection and Movement.
« Reply #1 on: November 05, 2011, 02:18:47 PM »
This is quite a big problem, and would require a working example to fully explain, but here are some pointers:

  • Each unit can have an FSM that tracks whether it's selected or not. E.g., Idle and Alert states.
  • Mouse clicks or touches can broadcast a Command event with associated EventInfo (e.g. MoveTo event with MousePick coordinates).
  • Units in a Selected/Alert state would respond to Command events, while units in an Unselected/Idle state wouldn't.
  • Figure out the list of Command events the game needs, and the states the Units need to respond to these events.

You will probably also need some collection to keep track of selected units. There are a few ways to do this in Playmaker:


You can then iterate through this collection when needed...

Hope this helps some! Will try to get some basic RTS samples into the next update.

Andrew.Lukasik

  • Full Member
  • ***
  • Posts: 134
    • my twitter @andrewlukasik
Re: Help needed with RTS like Unit Selection and Movement.
« Reply #2 on: November 05, 2011, 02:35:51 PM »
To handle selection I would try to do this with Screen Pick instead MousePick.

If you want to have region selection I would start with reading mouse XY on touch/button start and end (this will give you selection region precisely). Then make series of raycasts with Screen Pick in this region to search for units available to select

matias

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Help needed with RTS like Unit Selection and Movement.
« Reply #3 on: November 07, 2011, 10:12:15 AM »
Tnx a lot, will try it out today.  Also our game doesn't have any kind of group selection, player can pick and control only one character a time. :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Help needed with RTS like Unit Selection and Movement. [SOLVED]
« Reply #4 on: March 21, 2013, 02:26:41 AM »
Hi,

 On the same kind of topic, I also created a working RTS selection system, that might come handy in your game. It's in the sample of arrayMaker package.

https://hutonggames.fogbugz.com/default.asp?W715

bye,

 Jean