🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Driving AI - tips for a beginner?

Started by
2 comments, last by oliii 8 years, 4 months ago

Hi,

I consider myself a fairly experienced game programmer but for some reason I have never had the pleasure of working closely with AI (besides fixing some nav mesh generation problems at work). Now I have this hobby project that involves physics driven vehicles driving on a heightmap terrain and I would like to add AI to it.

As a first task I would like to spawn a vehicle, be able to click on the ground and have the vehicle drive to that position, avoiding steep cliffs and other obstacles. To facilitate this I have integrated Recast and Detour into my codebase and I can already draw the path from the start position to the end position. That's the easy part (I assume).

Now, my vehicles are completely driven by the (Bullet) physics engine, ie. I apply torque to the wheels to accelerate/brake, rotate them to steer etc. In other words I would like my AI to analyze the current state of the vehicle and determine how much of each value to apply to each input to get the vehicle to go where I want it to go. Do you have any tips on how this is usually done? The driving AI is not supposed to race against the player, it is supposed to be more alike to the AI driving the Halo vehicles. But at this point I am really only aiming to get one vehicle move to a position set by the player, not dynamic obstacle avoidance or such.

I started looking into PID controllers since they seem to be the way to go. Any other similar techniques I should look into? Good articles? Even books?

Cheers!

Advertisement

You might want to look into AI steering behaviors. More specifically approach, wall avoidance, and collision. These are all usually modeled as physical forces acting on an actor to control it's motion.

It will be similar with a car, you could even simulate a car drifting should an over steer occur at a rediculous speed.

if you have a path determined, you'll have a list of waypoints to traverse. the basic AI is: steer towards next waypoint. if more or less facing it, go fast, else go slow.

these turn left, right, accel, and decel commands then get translated into steering and acceleration forces based on the vehicle physics model you're using.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

A few ideas... Although I'm not a specialist.

Generate paths for your AI to follow, heading, position, and speed to target.

If you use virtual inputs (brakes, steering, throttle), use P.I.D. controllers for smooth AI driver inputs.

Have some idealised representation of your vehicle so the AI can anticipate (braking distance, lateral and longitudinal grip limits, weight transfer, mass and inertia).

You can 'cheat' a little. For example, anti-lock braking systems, traction control, stability control, four wheel drive, and to each wheel independently, to keep the AI well behaved.

Then you have other behaviours to 'unstuck' AIs. Like reversing away from walls, traffic, avoidance, ect... Note that driver aids can sometimes be more of a hindrance (by implicitly increasing the turning circle, for example).

Everything is better with Metal.

This topic is closed to new replies.

Advertisement