# Collision Scenario, Detection and Response

I have AABB, BSphere, a Polygon Soup, a Triangle, a Plane, a Point and a Ray objects with a collision test that returns 'bool' if two objects collide or not.

How can I use the above objects to implement an appropriate collision detection for my game?

It's a simple game where a player walks inside a rooms, and does the 'escape the room' scenario.

My levels is much like old Resident Evil with those 'static' cameras inside the rooms, some items inside containers, a monster and few items laying around so you can pick them up if you want.

• A room is just a 'Sector' - it would be a 'Polygon Soup'
• A player and all Entities are AABB

My question is:

1. Is my collision tests that returns (true/false) is enough for appropriate collision detection or do I need extra info like the normal vectors?

2. Should I go writing this myself or stop playing around and use some open/free physics engine for a simple game like this?

What you have accomplished is collision detection. You will need more information to resolve this collision. Usually you need:

• Penetration depth
• Collision normal
• Point(s) of collision

There are many resolution schemes, some simple and some very difficult. I usually recommend people trying out "impulse resolution" first. I wrote some articles on this topic.

The equation used to create an appropriate impulse is:

j is the scale of the impulse vector used to press two rigid bodies apart. e is the coefficient of restitution, a value from 0 to 1 representing bounciness. V^A and V^B are the velocities of rigid bodies A and B involved in the collision. n is the collision normal retrieved by the collision detection routine.

Please see the article I linked for many more implementation details I've left out here for brevity's sake.

You should stop and use a pre-made engine if you don't want to spend a lot of time making your own. If you like to learn and have the time, then you should learn to do this on your own.

• Thank you very much, it was a pleasure to read the reply. I will go with my own impl. as i feel an Physics Engine here would be an overkill. Especially i need some really simple things in here. Thanks! – cdmstr Dec 18 '13 at 19:49

What else do i need to have in my collision Classes to perform collision response between all collision geometries? Do I need more info other than >return if two objects collide (true/false) ?

A collision test that only returns true/false is usually called an overlap test. This is due to the fact that this is the only info that it returns.

For more appropriate collision response you might also need:

• The intersection point between the two objects.
• and also the penetration depth.
• you might need the normal vector of the surface.
• And sometimes the time (t) of the collision especially when you are implementing dynamic collision detection, but I doubt that you need it for your simple game.

But determining what info you need depends on how you are going to implement your collision response and what info you need. For example if your collision response calculates the torque then you should calculate the intersection point to be able to determine where the force is going to be applied.

• τ is the torque vector and τ is the magnitude of the torque.
• r is the displacement vector (a vector from the point from which ![torque is measured to the point where force is applied).
• F is the force vector.

The reason I am showing the torque equation is that you need the collision point in order to calculate it (calculate r). You usually need the normal vector, which can looked up once you the know face that collided, so you can implement any kind of reflection or knocking back. But this is also not strictly needed since you can get a way with a simpler approximation.

Should I go writing this myself or stop playing around and use some open/free physics engine for a simple game like this?

You can do it either way, but in the end it's a personal preference especially if you are learning and not delivering a commercial product.

A physics engine will give you more options for your collision response. But it doesn't mean that it will be "better". A collision response might be as simple as knocking back an object.

Integrating a physics engine also means more work than what you might need. So you are the only one that can determine what is needed, and it's especially hard for us to judge without an appropriate context.

• Thank you very much, it was a pleasure to read the reply. I will go with my own impl. as i feel an Physics Engine here would be an overkill. Especially i need some really simple things in here. Thanks! – cdmstr Dec 18 '13 at 19:49