Questions tagged [collision-detection]

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

Filter by
Sorted by
Tagged with
1
vote
3answers
84 views

Unity2D Grid-based Sprite Movement and Tilemap Collision

I have just started working with Unity2D to simply learn how it works. I've been trying to get grid-based movement and collision with a tilemap working, and it's mostly there, but there's one bit that'...
1
vote
1answer
34 views

Why is Area2D not detecting collisions?

I am making a sidescrolling shooter and I am working on the shooting mechanism. I have two scenes, one contains a KinematicBody2D with a Sprite, position2D and a collisionshape2D and a second ...
0
votes
0answers
16 views

More smaller scripts or less larger in Unity 2d Development? Better or worse performance? [duplicate]

In my unity 2d game I had large amount of scripts which were components of different enemies and obstacles. All of them were checking for collison, had FixedUpdate, Start and OnCollisionEnter2D and ...
1
vote
1answer
49 views

Check if a 90 degree rotation will cause a collision

I'm practicing Unity by developing a 2D game where the player has to stack tetrominoes falling from the sky. The problem I've ran into is that upon a 90 degree rotation of the falling piece, the piece ...
1
vote
1answer
66 views

Voxel terrain vs AABB collision detection

I am trying to implement collision detection in a voxel game. Currently I check the side of the collision by finding the closest side and checking whether there isn't a solid block next to that side. ...
0
votes
0answers
37 views

Optimal data structure for managing AABBs to minimize collision check queries

Say I have thousands of 2D Axis-Aligned Bounding Boxes (AABBs), and a single point. I'm checking whether a point is inside a certain AABB before performing some expensive logic. ...
1
vote
0answers
39 views

Character movement on irregular surface in Unity

I'm currently implementing a system in Unity where I generate an approximation of a blood cell and treat it as a planetoid, as if you're playing Super Mario Galaxy, and you're running around the ...
0
votes
1answer
29 views

How do collisions work under the hood in Unity? Is it more performant to make (physics) Layers as specific as possible?

I'm trying to decide how granular to be with my layers. I assume there's some spatial indexing going on, but... Does Unity do work for every pair of objects on compatible layers? Will Unity do some ...
0
votes
2answers
108 views

Collision detection between transformed meshes (not primitives)

I know questions related to collision detection have been asked multiple times, but I find all of them like this and this depend on the assumption that I have some sort of measurement of the object ...
1
vote
1answer
65 views

Cannot properly get 2D top-down tile-based collisions

I am using HTML, CSS, and plain JavaScript for a 2D top-down tile-based simulation. I am trying to do collisions in which, for example, if I move up and hit the ceiling collision tile, I cannot ...
0
votes
1answer
44 views

Why does OnTriggerEnter2D/OnCollisionEnter2D work when there is no other collider object opposite?

my bullet: There is a Box collider (checked "is Trigger") It has Rigidbody2D (Gravity = 0, freeze rotation Z) https://imgur.com/T4j1QoO I added the "OnTriggerEnter2D" function ...
1
vote
1answer
32 views

Getting the contact point when using OverlapCapsule

I am trying to use OverlapCapsuleNonAlloc to determine all enemy weapons that intersect with my character's CapsuleCollider at ...
1
vote
0answers
28 views

Is treating object meshes as nav meshes a sensible strategy for grounding characters?

It bothers me that a lot of character controllers are written to rely on raycasting for movement along the ground. While this solution is very straightforward and general (especially in the sphere ...
0
votes
1answer
25 views

How to handle collisions for short obstacles across a range of scales?

A naive collision system in 3D RPGs can lead to mobs getting stuck on geometry that they would realistically step over and can be a major nuisance to many players. For most games, the solution is ...
0
votes
0answers
26 views

Weird Collision Response occurring between 2 objects

I have been trying to program collision response between two objects (with AABBs) and the response is not what I except. Instead of bouncing off (reflective to the collision normal) each other the ...
0
votes
0answers
26 views

Unity: how to make a kinematic rigidbody react to a rigidbody hitting it?

How do I make a non-kinematic rigidbody react to a "normal" rigidbody colliding with it in Unity? Like when the rigidbody hits the non-kinematic one, it pushes it back (note: not using the ...
0
votes
0answers
40 views

Compute normal of collision between two bodies, when multiple fixtures touch

I have a body made of multiple fixtures. Sometimes, when another body collides with it, Box2D detects contacts between more than one fixture. The figure illustrates this: the blue body is made of two ...
0
votes
0answers
14 views

How do get fast leaf nodes collide with a leaf node in bvh tree. ( I don't wanna traverse top-down )

How do get leaf nodes collide with a leaf node in bvh tree. I wanna leaf node list collide with a leaf node in bvh tree. I'm doing this traversing bvh tree from top node. But It really slow because ...
0
votes
1answer
123 views

Unity 2D - Raycast not colliding with collider in very specific circumstances [duplicate]

I've been trying to work out what could be causing this bug for days now but can't figure it out for the life of me. I'm trying to make a fish avoid the walls of it's tank in a Unity game I'm creating ...
0
votes
1answer
60 views

Problems with collision order of resolution

I have two objects, A and B, and I need help to solve the following problem about the collision resolution order: A and B are moving with the same speed, and they don't move both at the same time A ...
0
votes
0answers
12 views

How to find the center of mass from CapsuleCast in unity

Is there an easy way to find the center of mass from a CapsuleCast, or should I find the geometric center of it?
0
votes
1answer
67 views

Best practice for detecting enemy death in 3D platformer

I'm building a 3D platformer, and I'm having issues figuring out how I should determine whether the player has effectively jumped on an enemy to kill them. My current approach uses "hurtboxes&...
0
votes
2answers
60 views

Collision filtering in Box2D: running out of bits

I have a physical simulation on the streets of a city. The simulation is 2D but in a few points it could develop on multiple "layers": for instance bridges or underground tunnels. I may have ...
1
vote
1answer
39 views

How to prevent GameObject from moving?

I am making a pong game and here's the problem. The ball hits the enemy paddle and instead of reflecting the ball just takes the paddle with it. Ball Brains - ...
0
votes
2answers
88 views

Rectangle collision not working!

I'm making a simple game in C# and i'm having some problems with rectangle collisions. What i'm doing is checking if two rectangles intersects, checking the side of collision and then moving the ...
0
votes
0answers
19 views

Rigibody2D remove push-power

I have a player's prefab. The game is online, so when the player joins I place this prefab on the map. There are other players on the map. The player himself is controlled by Rigibody2D component ...
1
vote
1answer
106 views

How does a game like slither.io handle collision?

This question can be generalized to "how does one efficiently determine if a collision has taken place between curvy lines" On https://slither.io there are snakes that players play as that ...
0
votes
0answers
52 views

How do I expand my simplex in Expanding Polytope Algorithm (EPA) when the origin lies on it?

I'm doing GJK + EPA in 2D for collision detection + resolution. For GJK, I was using the vector (1,0) as my first support direction. However, if the origin happens to fall exactly on the simplex line (...
0
votes
1answer
45 views

How to detect when a shot hits the opponent from behind?

I'm making a game where the enemy can turn on its own axis in 360 degrees (top view game). The player-controlled character has a bow. With this bow he shoots and deals damage when he hits the enemy. I ...
0
votes
1answer
56 views

Pygame logic to make a player stop at obstacles without overlapping them

what's the best logic to force the player to change its direction when he's just next to an obstacle (building, rock, tree..) ? I know this is related to collision detection but maybe my logic isn't ...
0
votes
0answers
31 views

Why does Lerp not reach target if setting rb.position, but setting rb.transform.position works?

I don't understand the logic here. I have the following script which makes a player jump towards a target: ...
1
vote
1answer
159 views

Can't check collision between a mask and a rect in pygame

I'm new to using masks in Pygame and I'm having trouble with them. I have already learned how to check collisions between two masks but I'm wondering about an effective way to check collisions between ...
2
votes
0answers
54 views

2D game make precise collisions

I am currently creating a personal 2D tile map game in Java. This is the first time I have attempted to make any sort of game, so I don't have a lot of techniques known by experienced developers. ...
0
votes
1answer
32 views

How can I create a good physics colliders for these models in Unity3D

I need to make a 3D colliders in Unity with those forms. I don't want to use any Asset Store asset if it's possible. There are two models: both are cylinders but they have some deformations (see image ...
0
votes
0answers
74 views

Unity OnTriggerEnter2D doesen't check Z Axis

I am coding my game's collisions using onTriggerEnter(). The problem is that it only checks X and Y axis and not the Z one, and that is causing me some problems ...
0
votes
0answers
33 views

How can I "tilt" my grounded raycast?

I'm working on a 3D game with a spherical collider for the player. My ground check looks like this, where I'm currently hardcoding Vector3.down as the direction: <...
0
votes
0answers
25 views

Player catches on tile map collision, even with common fixes

I am making a simple 2D platformer in Unity. I have a tilemap and I started noticing that the player catches on the tiles during gameplay. I move the player using ...
0
votes
0answers
82 views

How do I reference specific child objects in OnTriggerEnter2D

I'm currently trying to check if child objects, whose parent is running the script, are colliding with things. It doesn't matter what they're colliding with on the layer, I just want to know which of ...
0
votes
1answer
68 views

Issues using Physics2D.Linecast for Movement Collision

It's quite possible I'm missing something obvious (I'm still rather new to this) despite checking the documentation, but I'm at my wit's end with this issue. I'm attempting to add simple linecast ...
2
votes
1answer
148 views

Floats vs. Ints for position and collision

So I’m writing a player class and using floats to store the positon and velocity (Vector2) as well as using it when drawing. When it comes to collision I get the player bounds using this code: ...
0
votes
1answer
26 views

How to detect all vertices within collision Area?

Using collision detection algorithms such as MPR (Minkowski Portal Refinement), GJK (Gilbert–Johnson–Keerthi distance algorithm), you can calculate the penetration depth in the collision. For 2 mesh ...
0
votes
1answer
67 views

Pygame some methods aren't working properly (collidepoint and get_rect)

I'm making a game menu in Pygame, consider the following block of code: ...
0
votes
0answers
9 views

one collider for 2 combined object

I have an obstacle that composed of 2 game object, but when the player collides it, it gets in OnTriggerEnter twice when the obstacle have 2 different collider, which is what it should be, of course. ...
0
votes
0answers
47 views

Sphere-ring collision detection

I'm making 3d basketball throwing simulator and I'm stuck with the sphere-ring collision detection. It's easy to find the collision normal if we have the collision point with the ring, but I don't ...
0
votes
1answer
113 views

What is get_bounding_rect() method in Pygame?

I got used to get_rect() when detecting collisions in Pygame but I've just discovered that another method called ...
0
votes
0answers
81 views

How to detect ray cast collision on terrain gameobjects?

I made a script were an objects shoots a ray cast facing on the vertical axis and detects were the terrain is and then moves to the current terrain height wherever it is. This is so I can spawn an ...
0
votes
2answers
160 views

Why can't the player walk properly on the moving platform?

I'm making a platformer with Unity. In one of the scenes, I have a moving platform that moves back and forth. The problem is that the player can't walk (or sometimes jump) properly on the platform and ...
1
vote
0answers
121 views

With Unity, why this character with a rigid body and child element colliders doesn't collide with the floor and go through it?

I got an issue with my character going through the ground and actually going through all other elements with a collider. I'm going to try and show as much as I can of the current state of things. My ...
1
vote
1answer
76 views

Instantiated entities don't collide with each other

I've started to learn DOTS some day ago, and decided to create a simple project. When I added some simple physics to the game I faced the problem. I added one object on the scene and another ...
0
votes
0answers
253 views

Box collider not colliding with Character controller

I have a player with a CharacterController attached. The player can move around. There are obstacles which the player can collide with. These obstacles have a ...

1
2 3 4 5
47