How can I set up Vehicle AI?

I’m starting form 4.2 Racing Game Demo:
I can’t find documentation/tuts/info on how to set up a vehicle AI. I have tried to replicate some third person AI tuts… like “simpe move to” Target point… but my vehicle don’t wanna move.
I’m also not sure if following a thid person AI example could be usefull since the different nature of a vehicle pawn (acceleration, steer…).

any suggestion?

First, a vehicle should be a pawn (logically), thus it can be controlled by an AIController.
The AI is a challenge but if you put some effort in it, you can make it.

First, wrap the same commands as the player. The key input should invoke methods, which the AI also does, except it doesn’t make input but decides which function to call. So it can accelerate, brake and steer.

Now first you have to set a target and compute a path with NavMesh Pathfinding or something else.
You can iterate over the path and differentiate the waypoint deviation from the velocity vector and so you get a certain turn slope and can calculate a good amount of steer. While driving check the deviation from the way and correct steering.

That is no full AI, maybe you want to look over some theoretical tutorials or get some literature, but I hope I could help you with my first thoughts.


You could always use targetpoints as waypoints and find the look at rotation and update the steering value on tick. I did it like this and it worked fine. I did it in BP but the math would look roughly like this:

steering = (MyLocation - FindLookAtRotation(MyLocation, TargetPointLocation))/360

you want to get the look at rotation and find the difference between you and the look at rotation, that’s how far you need to turn. Then turn that into a number between -1 and 1 since that’s how steering works and set the steering to be that number. I would suggest making sure you are working with positive rotations though, so if it says -90 change it to 270. Things start to look funny if you don’t do that.

I did this with the vehicle map and got the buggy to zoom around the track with a bunch of waypoints. It even handles the jump and correcting for wobble on landing.

You will need to figure out a good system to control speed though. I have tried a few things and I just use what works for the situation.

Hello, I’d like to make the vehicle AI for my game, basically racing along a circuit, pick powerups and fire, but the resources are near to non existent, is there any documentation, tutorial, or other sources to look at? Thanks.

I recommend to you google this, because as a lot of tutorials (old) but still usefull in UDK tutorials about Race Games

Just google this:

udk race game

unreal race game

Hi Buscas31,
Thanks and sorry for the late reply but I didn’t get any notification for this.
I googled that but didn’t find anything about basic vehicle AI.

I’m trying to use waypoints but there’re a couple things I can’t figure out:
How do you find the difference between MyLocation (vector) - FindLookAtRotation (rotator)?
What do you mean by saying: keep sure to work with positive numbers?