Jump to content
  • Advertisement
Sign in to follow this  
GuyWithBeard

Driving AI - tips for a beginner?

This topic is 903 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!