Kinetic sphere collision resolve issue (DEF-2114)

Hi again team!

While fiddling with my platformer code, I noticed a strange behavior when resolving kinetic sphere collisions. Backtracking the code, a lot of which I borrowed from the Platformer example, I found that the issue is there as well.

Simply changing the hero’s collision shape from a box to a sphere, makes the platformer collision behave strangely. Every so often, you’ll experience a “fall” animation getting triggered.

When debugging the code for clues, I noticed that in the box shape case, the resolving was behaving much more stable. I.e. the y pos of the object remains fixed:

DEBUG:SCRIPT: geometry_contact  frame: 20   normal.y: 1.000000  d: 0.15277862548828  pos.y: 59.05579376220703
DEBUG:SCRIPT: update  frame: 21
DEBUG:SCRIPT: geometry_contact  frame: 21   normal.y: 1.000000  d: 0.15277862548828  pos.y: 59.05579376220703
DEBUG:SCRIPT: update  frame: 22
DEBUG:SCRIPT: geometry_contact  frame: 22   normal.y: 1.000000  d: 0.15277862548828  pos.y: 59.05579376220703
DEBUG:SCRIPT: update  frame: 23
DEBUG:SCRIPT: geometry_contact  frame: 23   normal.y: 1.000000  d: 0.15277862548828  pos.y: 59.05579376220703
DEBUG:SCRIPT: update  frame: 24
DEBUG:SCRIPT: geometry_contact  frame: 24   normal.y: 1.000000  d: 0.15277862548828  pos.y: 59.05579376220703

Whereas when using the sphere shape, you’ll notice that the y pos of the object will still creep downwards. Also note that the distance (“d”) remains constant:

DEBUG:SCRIPT: geometry_contact  frame: 45   normal.y: 1.000000  d: 0.15276968479156  pos.y: 59.05384445190430
DEBUG:SCRIPT: update  frame: 46
DEBUG:SCRIPT: geometry_contact  frame: 46   normal.y: 1.000000  d: 0.15276968479156  pos.y: 59.05383682250977
DEBUG:SCRIPT: update  frame: 47
DEBUG:SCRIPT: geometry_contact  frame: 47   normal.y: 1.000000  d: 0.15276968479156  pos.y: 59.05382919311523
DEBUG:SCRIPT: update  frame: 48
DEBUG:SCRIPT: update  frame: 49
DEBUG:SCRIPT: Falling
DEBUG:SCRIPT: geometry_contact  frame: 49   normal.y: 1.000000  d: 0.61134397983551  pos.y: 59.05406188964844
DEBUG:SCRIPT: update  frame: 50
DEBUG:SCRIPT: geometry_contact  frame: 50   normal.y: 1.000000  d: 0.15276968479156  pos.y: 59.05405426025391
DEBUG:SCRIPT: update  frame: 51
DEBUG:SCRIPT: geometry_contact  frame: 51   normal.y: 1.000000  d: 0.15276968479156  pos.y: 59.05404663085938

Another thing that is interesting, is that the physics debugger shows the contact normals differently, although it reports the normal (0,1,0) in the message:

Edit: Found this thread that sounds very similar, I too have this behavior every 33 frames!

3 Likes