Download

Does UE4 support movement style of StarCraft 2?

In a game I’m developing, I’m looking for a existing way(or component) to achieve group movement of RTS which likes StarCraft or WarCraft style. My purpose is that all moving actors are able to avoid each other, and when they reached destination, they can search a position closing to the position of destination to stay.
I knew that there’s a property of MovementComponent: bUseRVOAvoidance, when set true all actors would avoid each other when moving, but it’s not perfect as StarCraft, sometimes actor would move sideways, and when actors reached destination, they would stay as a circle.
does UE4 have any component to implement RTS style movement?

Not by default, this is something you’ll have to write.

RVO avoidance is actually really easy to do / program in, but it relies on ensuring that the object automatically orientates itself towards the direction it’s travelling. It’s great for characters / bipeds, because in UCharacterMovementComponent’s case all it does is interpolate the rotation capsule component of the character to face that direction. It looks like the characters are making the decision to walk away from each other, but actually all the engine is doing is modifying the velocity.

Of course that’s all it does in Unreal, anything more complex like, like staying in a certain formation while moving, you would have to write yourself since it’s quite implementation specific. I haven’t done anything like this personally, but it’s something I’ll need to do eventually so this is what I’d start with.

  • First thing would be to create a set of formations, and the easiest / cleanest way I can think of would be treat the central-object as the formation origin (or create some kind of proxy object), and create a bunch of positions around that one that are treated relative to the center. All of the other objects in the group just try to move to those. I’d probably create some kind of ‘Group Manager’ to easily keep track of which objects are slaves to whatever other objects.

  • The central object (you would pick a ‘leader’ object for each move), would actually ‘plot’ the path via navmesh, and as it moves, you also move the relative locations of the ‘formation’ and make all the ‘slave’ objects move to those points. Leader / Child movement like this is pretty common in RTS games with lot’s of units I believe, since it saves massively on pathing calculations for large groups of objects.

  • With the proxy object, you could modify the ‘size’ of it based on how many units are in the formation, so it will try to pick routes that allow all of the slaves to stay in formation.

  • You could get really crafty with it, and adjust the ‘speed’ of the slave objects based on how far away from their target ‘formation’ point they are, so that as the group turns they all try to stay in the same formation. Kind of like Age of Empires units do…

Honestly I’m just thinking aloud here. Doesn’t seem like a bad approach though… If you do anything like this I’d be interested to see it at least.

thx so much! your suggestion is very helpful. I’m not sure I can work it out perfectly, but I will do my best to achieve.
have a nice day!