• What is your GameDev Story?

Archived

This topic is now archived and is closed to further replies.

A few questions about ray based collision

This topic is 5344 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I''m currently in the midst of writing a dynamic 2d collision detection system. I don''t know much about the actual mathematical terms and formulas, but I have really good visual memory and thinking skills, and I''m basing all my math on how it would probably work in real life. Anywhoo, here is the jist of my collision system. During each entities collision logic, the entity loops through a list of dynamically generatered boundries. It tests to see if it collides with them by shooting out rays from each particle(pixel) on the side of the entity that is facing the random boundry. The ray''s length is as long as the difference the entity would travel in one frame, basically the ray is as long as the entities velocity is. If the endpoint of the ray goes through or touches a particle(pixel) in a dynamically located object, a collision will happen. So now you hopefully know what I''m talking about, and you can help me out with a few questions. Is this what is known as vector collision, if not, what is the difference? As far as I can imagine, this seems like the best way to test for collision with dynamically generated entities/objects/boundries. Is this true, or is there a better collision detection system in the world of 2d? Thank you for all help. Now its time to get back to coding the damn thing! :]

Share on other sites
Well, per pixel and per frame checking is pretty much the highest resolution of detection you can use You''re working in the smallest, most atomic units possible.

The only issue I would see is exactly how and in what direction you shoot your rays. Instead of checking every random boundary, just check in the direction of velocity. Because your object surely isn''t going to collide with something it''s moving away from

Share on other sites
I was already checking only the bounds of the polygon that were facing the direction my velocity pointed. I''m glad that you told me the method I was using was the highest possible resolution. Because it was pretty tiring for a non experienced math dude like me to write the algorithm. It works absolutely amazing for weird convex polygon collision testing, but in the end i realized it''s best to stick with just sphere and square collision tests. I''m glad I got to actually write and understand the lowest level of collision dectection, good experience definitely. Thanx for the reply zipster.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• Forum Statistics

• Total Topics
634063
• Total Posts
3015308
×