Download

Setting up a character class for RTS units

Hi, I’m having issues wrapping my head around how to setup my classes for a RTS game. I’ve been trying to use the Strategy game as a base and I’ve managed to get my camera controls (zoom and move) working with a SpectatorPawn and a custom player controller but now I’m confused on how to add a controller for my units. I’ve created a character class for them, do I create a new controller just for them and how do I set that controller to be used on those characters?

This is quite a deep subject, and I am currently working on something similar. I would be willing to help you via Skype if you’d like, but I’ll try and point you in the right direction:
This is my setup:
Each unit derives from ACharacter and has a default Controller deriving from AAIController.
The PlayerController has bindings for left mouse press and release and while the move is held down, a FBox2D is created that represents the marquee selection. I then loop through all the selectable units and project them to the 2nd screen space and see if they are inside the FBox2D and if so, set them to selected(It is a bit more advanced than this, but it will give you a good start).
The PlayerController then has an array of selected units. When the right mouse button is clicked, the PlayerController tells each unit’s AIController to move the unit to the location of the click. My implementation still needs some work with unit flocking and whatnot, but it is a good start. (The build in crowd simulation stuff doesn’t give the right feeling as units slow down a considerable amount when near other units, whereas I would like them to try to remain at their max speed and find a route around the units in the way).

Anyways I hope this helps, if you have questions or would like to Skype then let me know!
Connor