Skip to main content
34 votes
Accepted

How can I detect the player being crushed in a 2D platformer?

I think you'll have to take the box's movement into consideration. That is, only crush if the box is moving towards the player. This is similar to other problems in platformers, where the movement is ...
congusbongus's user avatar
  • 14.8k
15 votes
Accepted

Solving obtuse interior corner collisions

There is an alternate way to think about solving this. You can do a transform by offseting the lines by radius of your circle then the solution is same as intersection of 2 lines. Image 1: You can ...
joojaa's user avatar
  • 399
13 votes

Solving obtuse interior corner collisions

I assume that you want a solution for collisions in general, which also works well for interior corners. When resolving a collision against one plane, do not move the circle perpendicular to the plane....
Kevin Reid's user avatar
  • 5,508
9 votes

How can I detect the player being crushed in a 2D platformer?

Have the "crush test" points be inside the gray box shown in your image #1 - i.e. kill the player only if you detect a hit on one of the pixels there.
Peteris's user avatar
  • 1,019
6 votes

How can I detect the player being crushed in a 2D platformer?

As someone who grew up with 80s platformers, my first comment is that the contact points must be exactly on the sprite, not anywhere outside it. There were few experiences more frustrating than dying ...
Graham's user avatar
  • 222
6 votes
Accepted

AABB to AABB collision response

There are continuous and discrete physics/mechanics. I do not know which one you are doing. Their main difference is in the detection, which you already have done. Thus, I will skip finding candidate ...
Theraot's user avatar
  • 27.2k
6 votes
Accepted

How do I apply angular velocity vector after a collision?

The angular velocity vector you've computed using the method you've shown gives you two things: The direction the vector points is the axis of rotation The magnitude of the vector is the speed of ...
DMGregory's user avatar
  • 135k
5 votes

Collision between AABB and Circle

To detect collisions between a circle and an AABB, you should find the closest point from the AABB to the circle. You can run the below code snippet and try to move the purple point which represents ...
Ghoster's user avatar
  • 51
5 votes

Collision between AABB and Circle

I've been thinking about this problem for a long time and looked at some of the answers here and on other forums. I came up with the following idea: Suppose the circle has radius ...
Jack Ding's user avatar
5 votes
Accepted

Calculate bounce and friction after a projection-based collision

The "velocity vector" is the difference between the velocities of the two objects. When colliding with a static (unmoving) object (such as the level), the "velocity vector" is indeed its current ...
Jibb Smart's user avatar
  • 2,470
5 votes
Accepted

Finding the contact point of two spheres

This is probably the simplest 3D collision check. Distance between sphere centers is length(c1.center - c2.center) Depth is distance - radius1 - radius2 = ...
Jimmy's user avatar
  • 9,029
5 votes
Accepted

Is there a generic formula to determine the angle of deflection off of a rectangle?

The edges of your rectangle are just straight lines, so the angle of reflection is equal to the angle of incidence: Now, if this surface has its own angle, we can factor that in. Call the angle of ...
phlp's user avatar
  • 126
4 votes
Accepted

Pattern for collision handling?

Well, as some kind of solution I may suggest that in your case you should use something called Double Dispatch: the pattern Visitor actually. Let's look at your example briefly: If the player and a ...
Joshua Light's user avatar
4 votes

Swept AABB Collision Detection Conflict with Tile-sized Gaps

Since you have a tiled world and an exactly tile-sized character, a first step to sort out this problem can be to recognize when the character aligns with a tile. In the falling-into-a-hole case, this ...
Kevin Reid's user avatar
  • 5,508
4 votes

Solving obtuse interior corner collisions

To find the position where the circle is resting against both planes, you could use following approach: We define the line k which is the bisector of the angle between g and h. Every point on line k ...
Benedikt Jensen's user avatar
3 votes

How to handle collision detection & response in voxel engine with slopes?

There is a fairly simple way to do collision detection between a single "voxel shape" and an AABB. It relies on the SAT (separating axis theorem) - finding a plane which separates both objects. As ...
JBeurer's user avatar
  • 467
3 votes

Adding collisions to a 3D mmorpg game

You need to keep splitting your world into little parts. There are plenty ways of handling collisions between a height map and objects, but in the end, every method has the same problem; The Amount. ...
Yosh Synergi's user avatar
3 votes
Accepted

Strategies for dealing with crowds at choke-points

Assign each movable object a unique index & prohibit an object with a higher index from moving an agent with a lower index. This will allow 'older' objects to nudge 'newer' ones, but not vice ...
Pikalek's user avatar
  • 12.4k
3 votes

Resolving Circle-Circle collision

Let's say the moving circle \$A\$ has radius \$r_A\$, starts at position \$ \vec p_A\$, and travels with velocity \$ \vec v \$ And let's say the stationary circle \$ B \$ has radius \$ r_B \$ and ...
DMGregory's user avatar
  • 135k
3 votes

Detect collision point

In 2D rarely you have only one point of contact. I never played with collision resolution in 3D, but i guess this case will be even more rare. As for the answer, take a look at Erin Catto's (creator ...
crueltear's user avatar
  • 361
3 votes
Accepted

Measure force of an impact to deal damage

This is commonly done with collision.relativeVelocity, something like this: ...
DMGregory's user avatar
  • 135k
3 votes

What to do with collision detection?

This problem of "I found a collision/overlap, now what do I do about it?" is called collision-resolution. There are lots of different ways that games handle this, roughly in order of ...
DMGregory's user avatar
  • 135k
3 votes
Accepted

Rectangle collision not working!

We can make this a bit simpler using Minkowski addition. We can shrink one rectangle down to its center point, and enlarge the other rectangle from its center by the first's width and height, and get ...
DMGregory's user avatar
  • 135k
3 votes

Rectangle collision not working!

Preface The answer from @DMGregory has some wonderful math that will most likely solve most if not all of your problems. While I would recommend working towards an implementation like theirs, I ...
DrewAtWork's user avatar
3 votes
Accepted

Find closest open space in grid of rectangles?

I did some tests and found that this method does work. First you need to find the nearest grid coordinates to the position of the dragged block (blue box). Then do a grid-based BFS on the target ...
Mangata's user avatar
  • 2,616
3 votes

How do I make soft tile-based collision?

You mentioned a list of goals you want to achieve. In my opinion, they cannot be achieved using a single out-of-the-box way. You can unify them by wrapping the existing physics engine, But each effect ...
Mangata's user avatar
  • 2,616
3 votes

Bouncing balls miss collisions, bounce the wrong direction, of lose momentum on one axis when hitting a corner

It appears that your code is fighting with the physics engine about who gets to control the velocity vectors of the balls. When there is a collision between two rigidbodies, then the Unity physics ...
Philipp's user avatar
  • 120k
2 votes
Accepted

Do two balls of different mass bounce different heights?

The answer to your question is: no, as long as the system you're referring to implies no friction, there are no external forces, and the material the two ball are made of can be ignored. In Classical ...
liggiorgio's user avatar
  • 4,866
2 votes

Collision handling for grid based games and simulations

Hard to say without knowing how movement is programmed. If your "simulation" is turn based you should be able to change the status of any tile. When the creature(s) move then have the creatures A.I ...
arsogio996's user avatar
2 votes
Accepted

How can I calculate the penetration depth between two colliding 3D AABBs?

Here is a method to find the penetration depth between two axis aligned bounding boxes at low velocities. I've commented the code to explain how it works. ...
user1423893's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible