Game Development Community

A little more on the "Tunneling" problem

by Bruno Grieco · in Torque Game Builder · 05/18/2006 (6:20 pm) · 9 replies

I call it the "Tunneling" problem because when the player touches the wall it is teleported to it's opposite side.

I tracked it down, making an OnCollision Callback for the player. When the problem occurs, the %time variable passed to the callback was showing a "-0.0000" value which I thought was very strange.

In the engine : T2D/t2dPhysics.cc @ line 1747, in sweptPolyToPolyCollision, the pCollisionStatus->mCollisionTimeReal variable is what holds that info.

This variable wasn't actually -0.00, it was a very small negative number like -7e-7.
When it's a negative number it indicates that the polygons overlap and then they should be pushed away from one another. as the following code says :

// Set Overlapped Status.
    pCollisionStatus->mOverlapped = mLessThanZero(pCollisionStatus->mCollisionTimeReal);
	
    // Make sure the collision polygons are pushed away.
    // NOTE:- This is the overlap case.
    if ( (pCollisionStatus->mCollisionNormal * refLocalOffset) < 0.0f )
        pCollisionStatus->mCollisionNormal = -pCollisionStatus->mCollisionNormal;

BUT : in this case the polygons weren't really overlaped. Hence the very small number. what happens is that it reverts the normal, forcing the polygons to actually overlap and "tunnels" the player thru the wall.

I tried returning false when mCollisionTimeReal was very small, but that only made it ignore the collision and the player passed right thru the wall as if it wasn't there.

Any hints on how to solve this ? I beleive it must be related to Physics interpolation. When I raise the MaxInterpolation number, the problem increases.

#1
05/18/2006 (7:54 pm)
This would be good fodder for the bug forum.
#2
05/19/2006 (1:44 am)
Hey!

I had the exact same problem and Matt helped me solving it. All you have to do is setToRest() onCollision() with an obstacle.
#3
05/19/2006 (9:37 am)
@Oliver,

Thanks, that seemed to solve the problem.

Do you also had the problem of the player sticking to walls ? Perhaps this may solve it also.
#4
05/19/2006 (10:29 am)
No I didn't have such problems... but I have a similiar problem to the tunneling one you described. It happens when my character tries to push crates around from below. He "tunnels" through them and the crate moves a bit downwards and may even get stuck in a wall, jittering like crazy...

I never found out how to fix that one :/
#5
05/19/2006 (11:00 am)
Seems that below is a magic word. The tunneling also happened when hitting a wall from below.

There are some suspects I'm rounding for this :

1) swept collision polygons : There could be something related to the order of how the vertices are arranged that it yields an inverse normal in the calculation.

2) This very small mCollisionTimeReal : It looks more like a floating point precision problem than an actual value. Calling mAbs() with this thing yields absurd values.

What happens with #2 is that it inverts the collision normal, so the character is tunnelled thru the polygon instead of the other way around.
#6
05/19/2006 (12:32 pm)
Sounds interesting... maybe this should be moved to the bugs forum? ;)

Another hint I can contribute is this... The bug seems to disappear if i make my collision box of the character much bigger.

Right now my collision polygon looks like this(ripped straight from my t2d level file) :

CollisionPolyList = "-0.24 0.62 0.18 0.62 0.18 0.98 -0.24 0.98";
      LinkPoints = "-0.09 -0.68 -0.09 -0.68 -0.09 -0.68 -0.09 -0.68 -0.09 -0.68 -0.09 -0.68 -0.09 -0.68 -0.09 -0.68 -0.09 -0.68 -0.09 -0.68 -0.09 -0.68";

That LinkPoints list really gets me wondering... i NEVER set any link points to my object... that's just weird. Maybe another bug?
#7
05/19/2006 (12:53 pm)
Never mind moving the thread to the bugs forum. The collision system is FULL of bugs. They have a scheduled to-do list before they start debuging the physics system.

IMHO you should just delete that line from your level file. It seems like a level editor bug that generated that.

Also notice that you have a list of the same link point ( -0.09, -0.68 )
#8
05/19/2006 (10:33 pm)
There is a LB bug in Beta3 where your link points get duplicated... if you m ount something in the level builder, when you reload your level (even when you hit play and then stop again to go back to your level) it creates a new link point where your mount was... delete these link points, if you get to about 20-25+ of them it will crash the engine and your level might be lost. We already have this issue fixed and it will be in the next release :)
#9
05/19/2006 (10:47 pm)
Woah, thangs for the warning.