Skip to main content
gamedev.net
🔒 Locked

Collision Detection

Started by GambitSnax 5 replies 850+ views
Original Post
GambitSnax
GambitSnax
I'm working on a program atm where objects move around the screen and avoid all other objects. The way I plan to do this is via two techniques. The first is projecting a rectangle that is as wide as the moving object and as long as the velocity, in front of it, and check to see if that rectangle collides with any objects and adjusts accordingly. The other method is to project 3 lines out from the object, at different angles, and check to see if these collide with any objects. Could anyone give some advice on how to perform this? Currently all my objects are simple shapes, (rectangles, circles, triangles etc.), they have a position vector, and the approriate set of vertexes gets drawn around that. Cheers in advance. :)
Zakwayda
Zakwayda
Assuming the mods don't mind, you might delete this and repost in math & physics (or perhaps jollyjeffers will move it there), as this has a lot to do with collision detection and very little (if any) to do with DirectX. I'm sure you'd get some good feedback in M&P.
jollyjeffers
jollyjeffers
Quote:
Original post by jyk
...or perhaps jollyjeffers will move it there...
Done! [smile]

Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
Zakwayda
Zakwayda
Quote:
Original post by GambitSnax
I'm working on a program atm where objects move around the screen and avoid all other objects. The way I plan to do this is via two techniques. The first is projecting a rectangle that is as wide as the moving object and as long as the velocity, in front of it, and check to see if that rectangle collides with any objects and adjusts accordingly. The other method is to project 3 lines out from the object, at different angles, and check to see if these collide with any objects.

Could anyone give some advice on how to perform this? Currently all my objects are simple shapes, (rectangles, circles, triangles etc.), they have a position vector, and the approriate set of vertexes gets drawn around that.
Re-reading your post, I see you mention objects avoiding each other. Is this just a collision detection problem, or is it more of an AI problem? That is, do the objects need to 'look ahead' farther than the next simulation step?

I can make some suggestions in the collision detection area, if that would be helpful. If it's more of a predictive AI problem, I think there are some good references available on steering behavior (I would google for this last term).
GambitSnax
GambitSnax
Ahh, I did forget to mention that I was working with DirectX 9 and I did think that it had some built in methods for calculating collisions and hit tests etc. But maybe I'm wrong :)

I regard to whether it was object avoidance or collision detection, it is object avoidance, but the method by which I want to implement it, is by projecting objects and lines in front of the real object and calculating collision detection on these dynamically generated objects. From these collision detections, I plan to adjust the object's velocity to avoid the object in front of it.
deftware
deftware


I suppose what I would do, is project a point infront of the object in question, then from that point check a circle/sphere radius that is the length of the distance from the object to the point.


So basically you have your object, it's projecting a line out X units, so check a circle that has X units radius for objects that are inside the circle or touching the circle, and avoid them.

So the object would be projecting a big circle infront of itself, while lying on the very edge of this circle.

I think that would be cool :D
[ deftware.org ]
Zakwayda
Zakwayda
The suggestions made in this thread might very well work fine, but if you're interested in previous work on the subject you should google 'steering behavior'; I'm fairly certain there are some good references on this topic available online.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.