Avoiding a possible collision

Started by
1 comment, last by cybrgeek 22 years ago
In my game I have objects that move around the x and y axis, and I need make it so the enemy ships don''t run into each other. Right now I have code to figure out if they will collide by calculating at what points their paths intersect based on the slope of the line they are traveling, and then I calculate how much time it takes each both objects to reach that point, if that time is within x seconds then I know that a collision is possible if both objects continue with the same direction and speed. The problem is it looks really bad when two enemy ships are coming after the players ship, and they crash into each other. I''ve been working on ways to make them avoid each other, while still moving towards the players ship, but I can''t figure out a way that works well. Is their any standard way of doing this? I''ve tried things like having one object slow down, but that doesn''t seem like the best solution, and doesn''t work if two objects are heading directly towards each other. I think it would be best if it was possible to calculate a point for the object to move towards that will cause it not to collide with the other object, but still generaly head the same direction, instead of just reversing direction.
Advertisement
What you are looking for is called ''Unaligned Collision Avoidence''. It is a part of the many boids routines out there. Any applet that shows flocking routines should have this in there.

A good JAVA example is located @;

http://www.red3d.com/cwr/steer/Unaligned.html

Unfortunaly this fellow is not allowed to make available source code, but his pages (sort of) explain it well enough to create your own system.


Thanks a lot, I really appreciate the help.

This topic is closed to new replies.

Advertisement