Questions tagged [collision-detection]

Collision detection is the determination of whether or not two or more entities make contact with each other during gameplay.

Questions about how to implement collision detection or dealing with specific implementations and scenarios which complicate the process fall under the purview of this tag.

This includes questions about methods to assist in developing a collision detection system, such as how to determine the points of shortest distance between two objects.

2465 questions
82
votes
6 answers

How does a collision engine work?

How exactly does a collision engine work? This is an extremely broad question. What code keeps things bouncing against each other, what code makes the player walk into a wall instead of walk through the wall? How does the code constantly refresh the…
JXPheonix
  • 923
  • 2
  • 7
  • 7
28
votes
6 answers

What is a good algorithm to detect collision between moving spheres?

If (for the purpose of collision detection) 3D objects are represented in a game by spheres, what is a good algorithm to detect a collision between spheres? If each object has a position as of the last frame and a new (desired) position, what is a…
kevin42
  • 4,506
  • 6
  • 27
  • 33
28
votes
6 answers

How to decide which GameObject should handle the collision?

In any collision, there are two GameObjects involved right? What I want to know is, How do I decide which object should contain my OnCollision*? As an example, let's suppose I have a Player object and a Spike object. My first thought is to put a…
Redtama
  • 395
  • 4
  • 9
25
votes
5 answers

Collision Resolution

I know quite well how to check for collisions, but I don't know how to handle the collision in a good way. Simplified, if two objects collide I use some calculations to change the velocity direction. If I don't move the two objects they will still…
CiscoIPPhone
  • 5,268
  • 3
  • 32
  • 39
21
votes
3 answers

How do I test if a circle and concave polygon intersect?

I have a polygon (sometimes convex, but often concave), and a bunch of circles with different radii. How can I find out if a circle is intersecting/overlapping with the polygon? I could split my concave polygon into convex pieces. Would that help?
Adam Harte
  • 2,444
  • 3
  • 24
  • 31
15
votes
2 answers

What are "distance fields" and how are they applicable to collision detection?

I was looking at some efficient methods for collision detection in a scene with both static and dynamic objects when I came across "distance fields." I tried to search and understand this concept, but I could only find papers written in very complex…
Muhammad Omer
  • 299
  • 1
  • 2
  • 6
15
votes
2 answers

Best/Efficient way to implement a 3d Collision

I've already programmed a 2d based collision system for a previous game. It was my first collision system and it was ugly. I was looking for collision between objects by checking all objects with all objects. I've already heard about a grid system…
13
votes
2 answers

How does one perform collision detection on objects made of many small triangles?

I understand that any shape can be created (or approximated) by smaller triangles. Any rectangle can be created by 2 smaller triangles. Any circle can be created by many thin "pizza slice" triangles. How does this translate to collision detection? I…
JackOfAll
  • 299
  • 2
  • 5
9
votes
3 answers

How to detect collisions between sprite and a user generated shape of some sort?

How to detect a collision between a sprite and a user-generated shape of some sort. For example. There are some objects on the screen. The user takes their finger and draws a circle shape around an object (The selection rule is painting circle…
Huwell
  • 91
  • 1
9
votes
4 answers

Circle inside circle collision

In one of my projects I have a game area in the shape of a circle. Inside this circle another small circle is moving around. What I want to do is keep the small circle from moving outside the bigger one. Below you can see that in frame 2 the small…
dbostream
  • 265
  • 4
  • 8
8
votes
3 answers

Ball vs 45-degree slope collision detection

I have a simple game in which the player moves a ball around. The ball bounces off of walls. Right now I have square walls(■) implemented: I use simple bounding-box collisions to check if the player will move into a wall when updating its x or y…
Qqwy
  • 556
  • 5
  • 19
8
votes
1 answer

Collision detection: a bunch of special cases?

I'm writing a simple physics engine in 2D. My first goal is to get collision detection working. I know that my objects will eventually be made up of primitive shapes, but I was wondering - would a collision detection library be composed of a bunch…
7
votes
4 answers

If I know a given action will result in a collision, should I allow the action to occur anyway?

I've finished programming my game engine, and now that I've been testing it, I've been noticing some graphics problems. The big one is that when a player tries to push against a wall, their character will "jiggle" against it as it constantly tries…
Raven Dreamer
  • 1,867
  • 2
  • 21
  • 38
7
votes
2 answers

How to detect collision with non-rectangular objects in 2D games?

Detecting collision with rectangular objects is quite easy. I am able to write simple tile based games. Now I want to learn to write non-tile based games in which objects may not be rectangular, for example, a mountain. Suppose I want an uneven…
Cracker
  • 497
  • 4
  • 10
6
votes
2 answers

Determining which line to collide with

I am making a platformer, where my player is represented as a circle and the ground is represented as lines. The actual collision detection and resolving works, it's just an edge case I can't find a solution for. I check on which line the hero is…
shinkiro1
  • 61
  • 2
1
2 3 4 5 6 7 8