Vehicles in RTS

Hi people, Hope you’re doing great.
What is the best way to create AI vehicles in RTS(Real Time Strategy) Game like ClashOfClans?

Hey there @Adeel_Yaqoob! For most RTS games, vehicles are almost always just a variation of the base entity class. Depending on the scale of your RTS you may need to run your own system, but for smaller projects using the usual pawns and navmesh shouldn’t be much of an issue. What scale of units would you be looking at? Mobile level like clash of clans or something larger a la starcraft/company of heroes?

It’s like StarCraft with good visual Quality. The pawn and Character class seem to be a bit too robotic for cars.

Technically the character move component can be utilized to make most movement systems if you’re making custom movement modes, but I get what you mean if using it out of the box. The Chaos Vehicles system in Unreal is significantly heavier (and overkill) for RTS movements so that’s likely not the best course of action. The best alternative if you’re going to have that many actors is to create a custom actor that’s more lightweight that can handle the movement itself.

Also I’ve got some bad news on the massive unit count front, the baseline replication system is well suited for accurate and simple multiplayer replication, but would fall apart at Starcraft 2000 unit scales. It’s not guaranteed to be unplayable, but networking wise it’d be extremely infeasible, Raven goes over it pretty well on this post here:

It’s not impossible, and some developers have taken to writing their own deterministic lockstep networking to handle it, but it’s a big task to say the least. If you’re up to it, you’d likely also want to write a custom character controller as the baseline character controller is quite heavy in large quantities, if you want to go that route I’d start with stress testing very early to see just how much you will have to optimize to get to the scale you’d want.

1 Like

Okay, So vehicle class doesn’t use the NavMesh, so would it be better to use this for vehicles or character class for it?
And you mentioned a custom actor that can handle movement itself. Won’t I still be needing to add a Character component for it or do I need to write my own code for movement?

You’ve got it right, the vehicles don’t use the Navmesh natively, only character classes do. There are some vehicle AI solutions, but because the vehicles are largely simlike, it’s massive overkill to use them in any situation where there’s going to be more than 10 - 20 running at once, as well as it’s far harder to control the way they move because they are physics based.

Character classes are the only ones to be able to utilize the navmesh natively, so you would either use a character class and define custom movement rules for the vehicles, or create your own more lightweight version but that also means you’d be handling the navigation yourself which unless you’re doing basic A* it could get complicated very quickly. My recommendation would be to put together a character class that you can only send forward/backward and turning commands to, reduce the turn rate, and for the most part it will work like a car. Then spawn 100 of them and test, then 1000, if the game can handle it great! If not, however be wary that character classes are decently expensive, so if you’re going to be going for large scale battles, you may need to write your own.

2 Likes

Thank You so much. That was really helpful <3