# 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,130 questions
Filter by
Sorted by
Tagged with
34 views

### trying to work out coords based collision [closed]

In this game I'm working on, both player and enemies are represented by 32x32 sprites(not using bounding boxes). I'm trying to make a system where if the x and y coordinates of the player and ...
193 views

### Splice enemy array to destroy enemy (js game)

I am currently working on a basic space invaders game. So far I have created the enemies, a main character, and a laser beam, collision detection between enemy and bullet, however when my bullet ...
728 views

### Separating axis theorem OBB vs Sphere

I am trying to implement collision detection in 3D between OBB/AABB and sphere. For this i'm using sat/separating axis theorem. For sat to work in 3D i need face normals of obb (sphere to face), each ...
34 views

### Affect of timeStep on PhysicsBodies in SceneKit

In SceneKit, I had a problem on collision of two dynamic spheres, when the one strikes to another with fast speed, it was passing through inside of it. After i have reduced physicsWorld.timeStep value ...
743 views

### Why is my spherecast returning an incorrect hit on mesh collider? (Unity)

I have a mesh collider that is largely a flat plane facing up. Any SphereCast against that surface should return a normal of Vector3(0, 1, 0), but that isn't always happening. When near an edge on the ...
310 views

### How to know the point of collision with another object in Unity5

I have a small problem and it would be very helpful, which could guide me. What happens is the following, I have an enemy (evil usb) in my scene, to the collisionar this enemy with my main player ...
151 views

### Handling exact collisions on character controller and/or other objects in unity? (eg. head shot, chest , leg,etc)

Hello all I have been working on games in Unity for a long while (making slow progress as I do it purely on my own , and of course you helpful people here on gamedev.stackexchange!) I've made lots of ...
113 views

### AABB test does not consistently detect edge-to-edge contact when bounds are very different in size

My function compares two AABBs for collision detection, and when they are around the same size it works fine, but I noticed that if I greatly decreased the size of one of them (or augmented the size ...
63 views

### Collision and changing the scene. C#

I'm running into a problem where I want to create some code that such that if an object (Cube) is destroyed, it to changes to another scene. Here is my code: ...
61 views

### libgdx - Problem occurring after collision detected

I have just implemented collision detection in my little 2d rpg-like game. I'm using Tiled for the maps, mechanism is simple - I have one layer called 'collision' in my tiled map, and while loading ...
55 views

### How to implement level-player collisions resolution?

I want to create simple collision response system (physical simulation is not required now). It is needed just that player can't go through walls. I consider some variants: - Just create a set of ...
1k views

### How do Axis-Aligned Bounding Boxes update with rotations?

I have a bounding box class with a min (x,y,z) and max point (x,y,z). The object that is being rotated has a rotation matrix (3x3 matrix), but I don't know how to update the bounding box with ...
287 views

### How to Design a Generic Collision Detection System?

I'm designing a C++ 2D collision module, and I ran into a problem designing a system where the collider is unaware of the shape it's colliding against. I'd like to have a abstract base class called ...
226 views

### Physics.IgnoreCollision not working right after invoked

When invoking Physics.IgnoreCollision in Unity, it seems work but it still have collision detection right after creation. I have this issue with ejecting empty case after gun fire, it's spawning ...
188 views

### How do you find the collision between 3D boxes and 3D QUAD face meshes?

I have an axis aligned bounding boxes for 3D object collision, but I have a complex 3d mesh that's divided into 3d faces so I want to check for bounding boxes and collision with the faces of that ...
88 views

### How can i collide two bodies without filtering(collision filtering)?

I have two bodies with fixtures. One is platform or ground and other is the player itself.I want to collide the player to the platform without bit filtering.How can i do that?I can see the rectangular ...
1k views

### Unity: Water shader vertex offset - how to add mesh collider which updates with vertex offset?

I have written a shader (in the new LWRP shader graph) which simulates an ocean with vertices which offset to create a moving "waves" effect. I believe that in order to have objects "float" on my ...
58 views

### How do you create hitboxes that will detect stationary targets too?

I've created a basic attack combo system that chains 3 attacks together. When the player clicks the mouse button, it enables a boxCollider2D attached to the player. The boxCollider is a trigger and ...
400 views

### Detecting collisions without rigidbody

I have a car with the following aspect: As you can see, colliders are locally static, because they are separated from the original rigidbody component. Well, as you can suppose, I have a problem, ...
138 views

### Does destroying body also destroys the sprite?

Suppose a sprite is attached to a box2d body. And world.destroyBody(b); is getting called then the sprite also get destroyed or it stays there in memory. In my ...
177 views

### Object moving by adding force to Rigidbody bouncing off where ground objects met

I have a object that moving by adding force to rigidbody. With just big flat plane, it works fine but with connected small planes, sometimes(actually not sometimes, a lot) the object bouncing off or ...
164 views

### Getting false positives with SAT

I've been trying to get proper collision detection with SAT in 3D. I started of with this post: How many and which axes to use for 3D OBB collision with SAT. I've been trying to get the right axis to ...
57 views

### VRTK ignores IsTrigger

VRTK allow collision detection by adding the VRTK_HeadsetCollision, VRTK_BodyPhysics, VRTK_HeadsetFade and VRTK_HeadsetCollisionFade scripts into Unity. This works so that in VR when I walk through a ...
125 views

### Cache friendliness of AABB-Tree: binary vs N>2

I found that state-of-the-art physics engines like Bullet and Box2D all use binary AABB-Tree for broad-phase collision detection. I wonder, did anybody tested AABB-tree with >2 branches per node ? ...
143 views

### 2D Per Pixel Collision Detection using Animated Sprite

I am using MonoGame 3.6 and Visual Studio 2017. I have been trying to find a solution online to do per pixel collision detection using an animated sprite that I am drawing from a sprite sheet. Using ...
900 views

### How to optimize collisions

I'm building a 2D MORPG using JavaScript, Node JS and socket.io To prevent cheating, I have to run all collisions for all players on my server. I'm currently doing fairly simple square collisions ...
73 views

### Collisions between two objects in 2D space

I am implementing the collisions of my game in javascript, and at the moment what happens when the objects collide is that they have their speed changed to 0. What I'm starting to want to do is to ...
81 views

### Bug with OnColliderEnter/Exit when colliding with multiple objects at almost the same time

Unity Version: 2017.4.1f1 I currently have a game with a jumping mechanic. I only want the jump to work where you're on ground, so I have planes on top of everything, which, if you are on a plane, ...
360 views

### Can I test collision inside an edge collider area in Unity?

I draw a triangle with the edge collider2d and I want the player to make an event when he reaches this area, so I set the collider as a trigger and, I used the OnTriggerStay2d function in my code! ...
1k views

### Unity Tilemap one way collisions

How can we get one way collisions using Tilemaps in Unity? There doesn't seem to be much online regarding this topic yet. From this link: https://answers.unity.com/questions/1471156/how-to-make-one-...
142 views

### Collision not smooth in unity3d

I am working on a project(Racing car). When it hit an object the object should be destroyed. The Object is being destroyed when it is hit, but the car stops for a moment after hitting like an obstacle....
210 views

### How do I create a HeightField in pybullet?

I've been looking for documentation on PyBullet, the python implementation of Bullet, but I haven't yet found a way to implement the btHeightfieldTerrainShape collision object, which I need to make, ...
605 views

### Ray-box intersection problem

I try to implement ray-box intersection algorithm given by the following code. However, I'm not really understand for two cases as shown in the following figures. Firstly, when the box is located in ...
237 views

### (unity3d) Raycast Tags: Object reference not set to an instance of an object not working!

Here is the code I have written for an AI: ...
3k views

### Is there a way to check if an object is currently colliding with anything?

I need to test from another Script on a different GameObject, whether a particular GameObject is colliding with anything (in particular using trigger). So, for my purpose, I don't need ...
40 views

### For loop only checking the last object

Hi I am using a for loop to check and see if my players character is colliding with a collision object in the game. But for some reason it only checks the last Rectangle of the list. ...
480 views

### Why RaycastAll misses some objects?

Update 2 (see below) I'm writing a turn-based game. During setup phase time scale modifier equals to 0, what prevents running of any physics-based code and FixedUpdates. User have freezed action and ...
106 views

### Game map for platformer megaman-style game

I want to make platformer game that would be sort of like megaman. I'm using SFML library for it. I have a problem with creating a map. Should I hardcode every single platform, add it colliders and so ...
71 views

### libgdx strange collision detection behaviour

I am currently developing a small Spaceshooter Clone. The project can be found on github I am having problems with my very simple collision detection (or better said some behaviour that I can't ...
359 views

### Character collision detection on 2D array tileset based map

I have a very basic collision detection working, but not quite there yet. Now as I understand I'm only checking against the left top corner of the character for collision detection. And it only works ...
39 views

### Collision of grenadelauncher shell

The shell of a grenadelauncher is very small (10cm) and the speed is very fast (80m/s). Collision detection using colliders is impossible. To get the collision point of a rocket launcher I send a Ray ...
376 views

### Is there a way to invert collision detection in unity?

I'm trying to make a drag and drop tool to make maps in my game (dungeon crawl). I would like to use colliders to define geometry, just invert the case so that collisions are good, not colliding is ...
79 views

### How to get character position in 2D map array by its position on canvas

My arrayMap consists of 0, 1 and 2. 0 is water and character is allowed to be on. 1 and 2 are ground and the collision should happen. To get and check what array number the character is standing on, ...
394 views

### How to check if NPCs are on ground or not?

I'm using Unity Engine. I see the common way to check if player is on ground is shooting a Raycast: How to solve the ground check problem? How to check if grounded with rigidbody I have a simple ...
112 views

### Resolving Circle-Circle collision

If you have a stationary circle with radius x, and a moving circle with radius y, when a collision is detected, how can you resolve the collision, such that the moving circle stop? I.e. What would be ...
118 views

### What graph Search algorithm (s) that can simulate the behaviour of a human searching in a forest

We are building a game , where a group of humans(AI agents) have to wander seperatly throughout the forest looking for a collectable item. The forest is represented as a 2d graph with the item ...
153 views

### How do i manage skill collision target in Unity?

I wanted to make a skill that can be used by both Player & Enemy. How do I make it such that the skill will not be colliding with the owner/caster or colliding with both? One stupid way I have ...
93 views

### Why is my AABB vs AABB code returning false positives

I am trying to do AABB vs AABB collision and the code is never finding a collision. ...