Hardon Collider and Acceleration leaves weird gap

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Aidymouse
Prole
Posts: 7
Joined: Mon Aug 13, 2018 10:09 am
Location: New Zealand

Hardon Collider and Acceleration leaves weird gap

Post by Aidymouse »

Hey there,

In the game I'm working on at the moment, the field is constructed of hexagons, some of which are solid and impassable. I notice something weird when colliding with the corner in between two hexagons, in that it leaves a little gap. After some experimentation, I found that it has something to do with the acceleration of the object, because an exact replica of the object minus the acceleration doesn't have the issue.

I'm having this issue with the Hardon Collider, but I also encountered this program when I coded up an SAT algorithm myself.

Is this just the nature of the beast with 2d collisions? Any good way to resolve this? It's not major, but I thought I'd see if anyone knows how to fix the problem :D

White is the circle with acceleration, red is without. Note the tiny gap on the left.
Image

It's worth noting that the gap goes away when you stop trying to walk into the corner, it smoothly transitions into it as well, quite odd.
Image
Attachments
HCaccelerationweirdness.love
(37.65 KiB) Downloaded 86 times
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: Hardon Collider and Acceleration leaves weird gap

Post by pgimeno »

What's happening is that the sum of the individual separating vectors does not give you the correct separating vector for the collision with both shapes at the same time. HC is not able to give you that.

Your implementation of acceleration makes the shape keep its inertia even after the collision has been resolved, rather than stopping it dead or bouncing. As a consequence, you're approaching the shapes in smaller increments after the key release, which makes the error of the individual separating vectors vs the actual separating vector smaller. That's why it ends up at a point closer to the right position than doing one whole step at a time.

So, one approximate solution would be to perform the approach in several steps, resolving collisions at each step.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 28 guests