5
\$\begingroup\$

I'm currently brainstorming how the physics for my game engine is going to be handled. It's top down and I'm thinking of using ray casting for collision detection. I've reached two potential problems (I want collisions to be pretty precise but of course not to operation heavy).

  1. I'd like to use 2 different polygons for each object. One box to check collisions with first and then a polygon for precise checking. Is this wise to do when also checking collisions with ray casting? Or should I go for the more precise polygon right away?

  2. Say I'm going to move an object 10 units X-wise and another object 10 units Y-wise how do I know "when" along this movement they collided so that if they collided after moving 5 units I could handle events at that point? (One might bounce and move back the same 5 units traveled in the same execution of my update or get instantly destroyed in which case it wouldn't collide with a third object it otherwise would have collided with)

This could be a bit overkill but I still wanna know how one could go about handling this.

\$\endgroup\$

1 Answer 1

-1
\$\begingroup\$

I recommend using some middleware, so that all these kind of things are worked out for you.

Otherwise,

  1. Yes, this is a good idea, you can cheaply rule out certain intersections and avoid an expensive test. This is referred to as a bounding box.

  2. Using some middleware will mean this is worked out for you.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks for the reply. 1. I know it could help in the normal case, but will it really help when ray casting? (I should state that I haven't read much about ray casting yet and haven't tried it myself before.) I guess I don't have to do another ray cast once I find a collision with the bounding box. 2. I'm unsure what you mean with middleware, care to explain further? :) \$\endgroup\$
    – Ghork
    Commented Jul 13, 2015 at 6:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .