Day 50 collision epsilon question

Hi all,
In the Day 50 episode Casey uses an epsilon value to move the player slightly away from the wall after a collision. He mentions at the time that this is undesirable and that he plans to eliminate it in a future revision of the code.
As I understand it, the epsilon is used to cope with the imprecision in the intersection point calculation, to ensure that the player remains on the correct side of the line for tests in subsequent frames.
I'm just wondering how Casey might be planning to resolve this issue without the use of the epsilon value?
I understand that instead of using infinitely thin lines, one could use shapes with volume, and that would prevent tunnelling on the next frame. But it seems that you could still run into issues without using some kind of epsilon value to push the bodies apart. For example, if you had a row of boxes positioned side by side horizontally, with the player "gliding" along the top of them. If the player collides with the first box in the row from the top, the calculated collision point could conceivably be slightly inside the top of the box due to inaccuracy. So without moving the player back out again by an epsilon, if you continued to glide the player along the row of boxes, he could get snagged by the side edge of the next box in the row... unless I'm mistaken?
I assume we later use something like GJK to calculate the closest points inluding its distances and normals and correct penetration in an iterative way.

But right now we just correct the delta movement so there should never be any penetration at all in the first place. But if you happen to have entities which pushes you into the wall - entities will get stuck in other entities eventually.
A case which i am fighting right now by making a platformer with movable platforms which uses the same technique we are using in hand made hero.

Edited by Finalspace on
I suppose so, but "correcting penetration in an iterative way" doesn't seem all that much different to what's being done now, since assuming the same scenario of the player moving into the wall, iterative penetration correction would just result in the player being pushed out of the wall by a small value - which is basically an epsilon :)
If that's what Casey intends then fair enough, I was just wondering if he had a novel strategy for avoiding this.
Bastian78
I suppose so, but "correcting penetration in an iterative way" doesn't seem all that much different to what's being done now, since assuming the same scenario of the player moving into the wall, iterative penetration correction would just result in the player being pushed out of the wall by a small value - which is basically an epsilon :)
If that's what Casey intends then fair enough, I was just wondering if he had a novel strategy for avoiding this.


Sort of, but not fully implemented yet, because there are much more than just fixing the delta movement. You need to take the other velocity into account and correct position errors as well and introduce the concepts of mass to simulate pushing things - but not sure what casey has planned for this.

Maybe we use something like speculative contacts, which solves the velocity so it just touches the surface without any need for epsilons at all? Who knows...

If you are more interested in this kind of stuff, you can checkout my youtube channel: I made lots of tech applications for this kind of stuff: https://www.youtube.com/user/F1nalspace

Edited by Finalspace on
I'm not sure what tack we'll take when go revisit collision to do the full solution. My experience on The Witness has taught me that _actually_ guaranteeing correct behavior is very expensive, and probably not suitable for an action game with lots of entities. We will probably have to do something short of a hard guarantee, but rather something which makes it exceedingly rare that an illegal thing will occur.

- Casey
Thanks Finalspace and Casey for your responses.

Finalspace, I didn't realise before that speculative contacts doesn't use position correction. After reading more about it, it seems like a pretty interesting technique. It could well be of use in Handmade Hero :)

Casey, may I ask what techniques are in use in the Witness? I look forward to seeing which direction you take the collision stuff in future episodes.