Fast collision detection

Started by
0 comments, last by Qoy 24 years, 3 months ago
In my last game, I did movement and animation so that the characters moved x pixels per frame, etc, and capped the framerate. In the current one I''m planning to do movement so that it moves x pixels per second, so I will be multiplying speed by velocity to get distance. But I was thinking that for collision detection, this could present a problem, because the sprites might move through each other, and not ever touch if it is running on a slow system, but a collision should have still occured. How would I do collision detection that searches for a collision along a path instead of only at the exact location of the sprite? I have heard a little about vectors, but I am not quite sure how to do this... Thanks ----------------------------- "Truants move on, cannot stay long, some die just to live" From Immortality, by Pearl Jam http://www.crosswinds.net/~uselessknowledge
Advertisement
You can use math - there are equations that can tell you whether a line intersects something - or you can take the "lazy" (and slow) way, and just multiple points in between where the sprite was last time and where it is now...

For example, if your sprite moved 150 pixels, but you need collision detection accurate to 10 pixels, you divide the deltax and deltay by 10 and then step through the collision code 15 times (150 pixels / maximum of 10 pixels without a collision check = 15).

Mason McCuskey
Spin Studios - home of Quaternion, 2000 GDC Indie Games Fest Finalist!
www.spin-studios.com
Founder, Cuttlefish Industries
The Cuttlefish Engine lets anyone develop great games for iPad, iPhone, Android, WP7, the web, and more!

This topic is closed to new replies.

Advertisement