Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: matias 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? :)
-
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:
- Check out Jean's ArrayMaker addon: http://hutonggames.com/playmakerforum/index.php?topic=835.0
- Tag selected objects with a Selected tag. Remove this tag when unselected.
- Use the hierarchy and parent selected units to a Selection parent object. Unparent when unselected.
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.
-
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
-
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. :)
-
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