Public Group

# Collision Detection Tutorial

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

## Recommended Posts

I've searched everywhere but I couldn't find a tutorial that learns you how to code some real basic collision detection. Does anyone know a good tutorial? I'm programming in C++ and OpenGL.

##### Share on other sites
It's a pretty fleshed out topic, I think that you need to be more precise. For example when you say
Quote:
 how to code some real basic collision detection

bool checkSphereCollision(vector position1, vector position2, float radius){    if ( (position1 - position2).length() <= (2 * radius) )        return true;    else        return false;}

Which is a valid answer to your question, but that's probably not what you are looking for. General collision detection for arbitrary cases is not a basic issue, although you could do a brute force triangle-triangle check on your entire scene, but that won't extend well at all. You usually have specialized cases for different collision shapes.
For example a quick [google] revealed Basic Collision Detection. There is even a tutorial on NeHe for a few cases if you want it to be in the context of C++ and OpenGL.

##### Share on other sites
Here's a really great tutorial:

www.paulnettle.com/pub/FluidStudios/CollisionDetection/Fluid_Studios_Generic_Collision_Detection_for_Games_Using_Ellipsoids.pdf

##### Share on other sites
It'll help you if you first formulate what exactly you're looking for. 2D collisions or 3D? Just squares/blocks or arbitrary shapes? And once you're able to detect collisions, what kind of response are you looking for?

Anyway, you may find this tutorial on the Separating Axis Theorem usefull, if you're into 2D.

• ### What is your GameDev Story?

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

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634092
• Total Posts
3015464
×