Reputation: 3118
I am working on a car racing game. I am almost done with prototype, but one thing.I am unable to add opponent cars. I searched for steering behaviors, I found a cool tutorial for Wandering. But couldn't find much useful on path following.
I found this link, but dint help me understand much.
Does anyone help me with some good tutorial for steering behaviors, which would help me grasp the basic concepts..?
Upvotes: 1
Views: 914
Reputation: 64477
This is non-trivial. Cars don't just follow a path, unless you want them to behave unrealistically. What you need is an AI driver. A good driving AI checks what's in front of it and then makes decisions to steer more or less in one direction, or brake or step on the gas.
This article covers some of the basics.
For the simplest solution I suggest a waypoint AI where the car just tries to head to the next waypoint of a predetermined path laid out by you. Depending on the angle between the past, the current and the next waypoint the AI can decide how much to steer and whether to step on the brakes to make the turn. You need to be sure that the AI actually does recognize reaching a waypoint by checking if the car is in a reasonable range. The distance between two waypoints must be greater than this range, otherwise the AI is prone to skipping ahead or possibly even turning back.
Upvotes: 4