Hello everyone.
I’ve been developping an RTS for a while, and I’ve come across a huge issue : vehicles.
Now, I’m starting to understand why every RTS pack and all tutorials I’ve ever seen on UE4 only deal with infantries, and why RTS die during the process…
I’ve seen a couple tutorials and struggled with the problem myself to come to the conclusion that doing AI for vehicle in UE4 is cumbersome to a very unhealthy point !
The problem
So I’m trying to do a Right Click Move To kind of movement for vehicles. It works perfectly fine with Infantries but it is a real clusterf*ck for vehicles…
What I’m trying to archieve is a car/tank able to :
- Do a U-Turn in a very small area (or on place if it’s a tank).
- Follow the ground correctly (wheels or/and tracks).
- Brake within 1m (really fast full stop).
- Full stop even on a sharp slope (almost ignore gravity - very powerful brakes).
- Can work with both wheeled vehicles and threaded vehicles.
- Send minimal datas over network (Client-Server).
- Capable of huge acceleration & deceleration (in addition to powerful brakes).
Typically, I’m trying to archieve an AoW, AoA or C&C Generals kind of vehicles.
What I’ve tried
I’ve tried 2 different ways, both currently in a dead end, but both partially working…
1. Using Vehicle Component
The first thing I’ve tried was obviously to use the vehicle component. But :
- It is overkill : lot of physics, gear system, etc, which I don’t need. All I want are the wheels / track to follow the ground and acceleration/deceleration.
- IA MoveTo isn’t implemented by default like for infantries.
So of course, I’ve worked on an AI which work with the **Find Path To Location Synchronously ** node.
The hardest part for that version of the algorithm is to control the vehicle. I really don’t understand how and why, but this car is rolling on oil/soap all the time.
I need it to brake fast, and handle the road like a 4x4, turn super quickly, accelerate and decelerate like crazy. Even if it’s not realistic, this is what I want.
And this is the exact opposite of what this car is doing. It takes ages to brake, turn slowly, drift like on ice, etc… I don’t want it to drift AT ALL ! T_T
2. Using Character Component
The second way, of course, was to use character component. So the idea was to replace the mesh of the soldier with a mesh of a car, and use a Physics Constraint to allow the car to rotate to follow the slope.
Does it work ? Yes, and no. As you can’t change the root component of the character and can’t disable it’s collision without the capsule ghosting throught the map, this is really hard to archieve something great.
So I tried to give it some Z freedom, with like 50 units. It works, but when the caspule stop, as AI ignore deceleration, the back of the car jump like it just crashed into a wall. It is probably normal since the speed goes instantly from 600 to 0.
I’ve tried implementing some deceleration but on a 2m length, it won’t help, the car still jump. If I disable that freedom, the car cannot follow the ground correctly because of the stupid capsule component…
Your move, community/devs !
So here I am, in a dead end with 2 semi-working things. I am confused on which way to go, why, and how.
I’ve been stuck on that for a whole week, trying to figure out how to deal with it.
Another problem are the wheels. I don’t know how to deal with steering the wheels (with Char Component). I don’t even know if the wheels should be part of the skelton or separate meshes.
I’m looking for a way to make it work with both wheels and tracks (for tanks).
I don’t need the physics to be perfect. If the wheels are just here to add realism and do not provide any torque, I’m fine with it as long as everything I asked for is respected.
Any help / experience is very well welcomed.
Thanks !