# Questions tagged [collision-detection]

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

2,158 questions
Filter by
Sorted by
Tagged with
566 views

### Finding roots/zeros for collision detection?

For the most simple of 2D games, I have implemented a posteriori collision detection (overlapping rectangles) on the x/y Cartesian plane, but am now interested in understanding the basics of a priori ...
1k views

### When to detect collisions in game loop

My game loop uses a fixed time step to do "physics" updates, say every 20 ms. In here I move objects. I draw frames as frequently as possible. I work out a value between 0 and 1 to represent the ...
2k views

### Minecraft-style player-gound collision detection

The title pretty much says it all... (Minecraft is a game consisting of evenly-spaced cubes for terrain, like voxels) Note: I am using C# XNA. I am pretty sure AABB is the way to go, yet I don't know ...
498 views

### Detect walking on floor - works partially

I have a set of Gameobject blocks that form a floor with Box Collider and a GameObject with a Box Collider in it. My first hunch detecting hitting the floor was: ...
2k views

### Meaning of offset in pygame Mask.overlap methods

I have a situation in which two rectangles collide, and I have to detect how much did they collide so I can redraw the objects in a way that they are only touching each other's edges. It's a ...
1k views

### Multiple collisions within a single frame cycle?

So say you want to simulate several objects in two dimensions, just bouncing around in a finite space. Using AABB and sweep tests, it shouldn't be that complicated to calculate single collisions ...
1k views

### Need some advice regarding collision detection with the sprite changing its width and height

So I'm messing around with collision detection in my tile-based game and everything works fine and dandy using this method. However, now I am trying to implement sprite sheets so my character can have ...
1k views

### Collision response for 2D racing game

The title is fairly self-explanatory. I have a 2D racing game that utilizes per-pixel collision detection (the track is essentially two bitmaps, one for the graphics, one for collision data). The ...
1k views

### Collision detection between draggable object and world objects?

I have a game I'm making in Javascript that will involve combining items by dragging and dropping them onto each other. Think Alchemy or similar. So far, so good, but I hit a snag while trying to ...
382 views

### Rotating platform glitch in a 2D platformer [closed]

So I'm making a tiled platform game in C#/XNA where the whole world is constantly rotating. The huge hurdle was to find out what side of the tile the player was touching, and what angle it was. I ...
5k views

### How can I improve my collision detection's performance?

I'm new to programming and want to speed up the collision detection in my C++ 2D platformer game engine. Currently, only the player's collision detection works: Every frame, the player's update ...
2k views

### Boundaries in game development: How do “professionals” do it?

How do professionals do boundaries in a 2D game? The way I do is say I don't want the sprite to move into a certain area: ...
352 views

### detecting the coordinates where a bullet hits a mesh

I have a lot of complex objects in a scene and I'm looking for an efficient way to find which object a fired bullet hits, and to find the hit coordinates. It would be best if there was a lightweight ...
1k views

### How to calculate new direction after sprite collision

The scenario as you can see in the picture. A ball will be hitting a surface and I want to fairly correctly get the new angle after the collision.. I expect to know the X,Y coordinates of the lines ...
3k views

### How do I resolve a collision of a rectangle with two rectangular tiles at once?

I am having some problems with collision detection between a player and the environment in a tile-based game. I have a player objects, Tiles and what I call ...
71k views

### Simple collision detection in Unity 2D

I realise other posts exist with this topic yet none have gone into enough detail for me. I am attempting to create a 2D game in Unity using C# as my scripting language. Basically I have two objects, ...
1k views

### How to handle collisions without ugly conditionals and type checking?

(I asked a similar question, but this one is far more specific). How can I handle collisions without having to do a lot of type checking and if statements? People ...
8k views

### How can I use Rectangle.Intersect() to resolve collisions in XNA?

I have a 2D game written in XNA, and I've been trying to fine-tune my collision resolution. All of my game objects are squares, which means detecting a collision is easy - use the position and the ...
457 views

### What are the technologies that makes physics engines so good for raycasting?

again. This question is strictly related to this one so, what is the technology that makes physics engines suitable for raycasting? It is a particular data structure? Has it to do with the engine's ...
720 views

### Solving 2D Collision Detection Issues with Relative Velocities

Imagine you have a situation where two objects are moving parallel to one-another and are both within range to collide with a static wall, like this: ...
2k views

### Ellipsoid v. Box collision detection

I'm trying to write some collision detection code. ATM i have the code properly resolving Ellipsoid v. Ellipsoid collisions, and Box v. Box collisions, but Ellipsoid v. Box collisions doesnt work. ...
140 views

### Dealing with collisions across adjacent static bodies

The Problem: I have the following setup: A, B and C are rectangular static bodies in box2d. p is a circular dynamic body in box2d. The movement of 'p' is solely controlled by the current gravity ...
2k views

### Most efficient way to get the world position of the 8 vertexes of a Box Collider (C#)

What I am looking for is the most efficient way to get the world position of the 8 vertexes of the Box Collider of a freely rotated Gameobject. I cannot use collider.bounds since object is rotated, ...
3k views

### In Box2D, how can I check for bodies within a circle?

I'm trying to sample random positions to find one that is sufficiently far from other bodies. Hence I'd need to test for bodies within a given circle. So far, I've used ...
2k views

### Make my NPC “see” gameobjects around him in Unity

I have a walking NPC that will "see" the wall in front or behind him (2d gameplay) and that will react accordingly. I was thinking to attach him to an invisible collider that would react to objects ...
294 views

### Get normal dependent on collisions position

As I hask ask here I'm working on how my objects can move over the terrain and other objects. My proposal and also an idea in the answers was to calculate the rotation from the object with the normals ...
7k views

### Using uniform grids for collision detection - Efficient way to keep track of what a cell contains

I was looking for an efficient way to implement collision detection in a 2D game. A way that won't result in an O(n^2) level of complexity. A lot of people recommend to use Uniform Grids for this ...
14k views

### How to detect collision in Unity3D without rigid bodies?

The target platform of my game is mobile devices therefore I try to develop it performance oriented. It will be a strategy game so I don't really need physics in it, consequently I did not add ...
610 views

### What's the reason behind collision-boxes?

I was surprised that some games use extra models called collision-boxes for collision. What is the benefit of doing so? Can't we calculate collisions between the vertices of any game model? Is this ...
1k views

### How to perform simple collision detection?

Imagine two squares sitting side by side, both level with the ground like so: A simple way to detect if one is hitting the other is to compare the location of each side. They are touching if all of ...
745 views

### Roguelike 2D Collision Detection

I'm just a normal guy trying to do some basic collision detection but I suck at it. I either get stuck in a wall or I go in reverse in the wrong direction trying to update the player position to a non ...
299 views

### how to keep display tick rate steady when using continuous collision detection?

(I've just found about this forum). I hope it is ok to repost my question again here. I posted this question at stackoverflow, but it looks like I might get better help here. Here is the question: I'...
2k views

### 2D Collision: Check before or check after?

I'm using velocity to move my character, I just add/subtract 0.4f and then update the players position in the update loop. I was wondering, when would be the best place to check for collision? Do I ...
2k views

### Tile based collision detection failing when player is going too fast

I'm creating a side scroller and I'm have a problem with my collision detection. The collision detection works perfect when the player is falling at a constant speed, but when I implement more ...
785 views

### How can I handle fighting game collisions for complex animations?

Imagine that I have an animation like this. As you can see, this attack hits in three horizontal places. The opponent facing this player could be hit mid and low (standing or crouching). The same ...
5k views

### 2D Rectangle/Circle Continuous Collision Detection

I'm looking for a fast 2D continuous collision detection algorithm for circles and rotated rects. It needs to determine the time of collision. Both shapes may be moving at high speed, so the ...
2k views

### How can I normalize a vector if I am handling movment of each axis seperatley?

I am writing a 2D tile based game engine in XNA, and I've recently fine-tuned my collision detection using the answers provided here and more specifically here. The tile based collision detection now ...
420 views

### How do I find actors in an area on a poly-precise basis?

Ok, I've been asking various questions and getting some good answers, but I think I need to rethink my method, so I'll describe the problem. I have a player who has a big blue box in front of him. ...
6k views

### Finding if a point is inside of a mesh (Point-in-polyhedron)

How can I find if a point (Vector3) is inside of a mesh? Would this work for both concave and convex objects? I read somewhere that if you raycast in both directions of every axis (X, -X, Y, -Y, Z, -Z)...
566 views

### Separating axes theorem problem

I´ve been following this tutorial : http://www.dyn4j.org/2010/01/sat/ to help me understand and implement the SAT for collision detection in my games as I want to add a support for polygons. However, ...
1k views

### How to detect collision only in non-transparent texture?

I am developing a game using libGDX. I am trying to detect the collision between bee and tube. I am using the following code to detect the collision. ...
763 views

### multiple contacts for SAT collision detection

I have implemented SAT algorithm for obb-obb intersection and I am able to generate a contact for this collision type. My problem is that SAT only generate ONE contact and in many situation I need ...
194 views

### Torus World Collision Dection

I am looking for a collision detection solution for use when 2d screen wrapping. Specifically, when the image is split between the right and left side I can only detect a collision for a limited area....
1k views

### Designing Efficient 2D Collision for Topdown Shooter

This makes it the first time I'm posting here, so apologies if I stumble over beloved conventions. Currently, I'm trying to figure out how I want to handle collisions for a large number of entities ...
7k views

### Non axis aligned bounding box collision and physics

Exactly how much more expensive, and while we're at it, difficult, is it to have non-axis aligned bounding boxes in your framework? I realise that it very much depends on what you're trying to do, so ...
6k views

### How can I set up a Pong-style game using the physics system in Unity?

I've just been using Unity and chose to learn it by making a Pong game which sounded simple enough as a "hello world" type of game. My goal was to try and encompass enough of the built in engine ...
2k views

### Determining if a character is within the field of view in XNA

I'm trying to creating a field of view for the camera I'm making for a game. It rotates around a circle for 180 degrees while the head moves accordingly. I'm going to bound the field of view within an ...
1k views

### Android collision detection of a 3d object based on a 2d projection

I am writing a game for android. We have an orthographic view setup, but the characters (ships, projectiles, etc). The enemies / characters will be able to rotate about the x axis. The problem is that ...