Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

The subject says it all. I am making a 2d space game with newtonian physics and I need pointers on how to write an autopilot for it. The requirements are best explained by an example.

There is a target object which has speed and position vectors and there is a spaceship that is controlled by the autopilot. This spaceship also has speed, position and maximum acceleration. The autopilot needs to control the ship so that it either collides with the target or intercepts the target with matching speed and position.

Could someone give me some pointers how to achieve this behavior or perhaps even a ready implementation? I am sure someone has written something like this before and there is no point in reinventing the wheel.

share|improve this question
3  
The google keywords are "steering agent" – Maik Semder Nov 7 '12 at 21:45

2 Answers

You will probably find what you're looking for here:

Steering Behaviors For Autonomous Characters

Maybe in this article:

Steering behaviors (full article)

share|improve this answer

Many of the currently available steer libraries are based on either OpenSteer or Programming AI by Example and have one fatal flaw: they rely on forward-facing physics which are out-of-the-box incompatible with physics libraries such as Box2d.

To illustrate the problem: in almost every single one of the steering examples, the direction of the agent, is the same as its force. This, however, doesn't hold true with physics libraries, where the force of the object can be different to the direction the object is actually facing.

Solving this can be fairly non-trivial. However,there is a video that seems to be doing something similar related to the book "The Nature Of Code". In the book, the implementation has been left as an excercise (6.21), unfortunately.

Trivial way to handle this is to cheat, and adjust your agents graphics heading independently of physics, but this seem like a sub-optimal solution to me. What about situations where you want to preserve non-forward facing physics of the physics library, but yet be able to steer the craft using autonomous agents?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.