Game Development Community

RTS Controls, now with Behaviors

by Trace Kern · in Torque Game Builder · 08/02/2007 (12:12 pm) · 5 replies

This thread is intended to continue discussion on how to use/design behaviors to emulate common RTS style contorls. Things like mouse selection of single or multiple units. Right-click actions/movement. Saved selection groups. Etc.

Original discussion started here: www.garagegames.com/mg/forums/result.thread.php?qt=65414

Feel free to catch up over there. Don't worry, we'll wait.


Back? Okay, now let's get back to business.

#1
08/02/2007 (12:14 pm)
Decided to start off by copying my last post from the other thread.

Quote:Thanks for posting your behaviors Marc, I'll get busy chewing them up this weekend. :)

As for saving group selections, I think Marc might be onto something.
Just analyzing the logic flow from a non-behavior aspect, how would you handle it?

Most likely you'd have a method embedded into the onKeyDown (Is it onKeyDown or onKeyPressed or something else? Can't remember) for the number. Within this callback, check if the Ctrl modifier was used, if so check for a current selection from the Selection method/behavior, if found add the objects within that selection to a specified container object. If the Ctrl modifier isn't pressed, look for a saved selection within the container assigned to that number, and if found make the saved selection the new current selection.

Now how can we break this apart into behaviors?
I'm assuming that we're going to be adding the selection/multiselection/whatever behaviors to a specific object in the scenegraph, which may or may not actually be rendered to the window, correct?
If so, we could add yet another behavior to this controller object. One which contains our needed callback methods.

Would this be feasible?
#2
08/02/2007 (12:37 pm)
No problem

I agree on your point there.

I was actually thinking of a "player" object which is invisible, which is used to track the players keyboard input and hold other behaviors needed as well (like resources, current camera position etc for replay and all the like)
#3
08/02/2007 (10:21 pm)
Ahhh, yes that's pretty much what I was suggesting. Only instead of calling it 'Player', which could easily be confused with an actual player class, I'd suggest something more generic. Controller perhaps?
#4
08/03/2007 (12:38 am)
Hmm yeah I forgot about those RTS that have ingame Avatars like Spellforce and especially forgot group action adventures where the RTS selection etc is of use as well but where even more than one ingame representation exists.

So Controller is more likely to be a good idea.
Good point there.

As well as there is another thing this controller could be used for: camera pivot, an invisible "target point" for the camera to which it is mounted.
This could perhaps solve a problem I have with the MouseSelector, which I wanted to do the "move the camera while dragging if the rect is larger than X units, whereas X can be defined through another property". With a controller and behavior for this, this should be cleaner to get done and most likely simpler.
#5
11/04/2007 (9:28 pm)
What is the cleaness way to design behaviors so that if I click on an object and then click on its destination anywhere on the screen, it will automatically move to that position? I was thinking of using combination of AI/Move Toward and RTS/MousePointer and MakeSelectable? How should I track the objects selected so I can cycle through it? And also queue up a list of destination point it needs to visit and exec callback?