I’m building an RTS and am having some difficulty setting up the relationship between the controller and the pawns. I currently use one main pawn as the camera rig that the controller posses from the beginning. After that I want to be able to select/deselect pawns and feed them instructions from the controller. Any advice is appreciated.
Getting one controller to control all the pawns looks like a bad idea to me. Create an AIController subclass (let’s call it RTSPawnController), and create RTSPawnController subclasses for each of your different pawns, and spawn one controller per pawn. Then, have the player controller send commands to these RTSPawnController subclasses. For example, you might have a MoveToPoint function in the RTSPawnController which the player controller calls on selected pawns.
Are you really sure that it’s a good idea to have each RTS unit have it’s own instance of the AIController? Because that means you have many Behavior Trees running at once.
Not that I know what I’m talking about or whatever… I only found this post because I was trying to figure out how to organize the relationship between Behavior Trees, units, and AIControllers. If you’re sure that this is the right/best/decent way of going about it, then by all means.
There is a user on youtube who has done some extensive videos on RTS and AI movement you should check it out:
Unreal Engine 4 Multiple Units Selection and Move In Formation - YouTube You may find what you are looking for in his series.
Generally, it is a good idea.
I witnessed and profiled this kind of setup in production. Unless number of your units goes into thousands, modern PC shouldn’t have any problem with it.