Character In 3D Scene Is Having Collision Issues - Keeps falling for 1 frame


I’m trying to create a character in a 3d scene that can move forwards / backwards as well as jump / fall. I’m having this strange behavior where the character will periodically have a larger gravity value than usual (see video below).

It seems like ever 122 updates (at 60 fps) the check for ground collision fails, resulting in the character falling for 1 frame, resulting in a strange pulse like animation. This is caught the next frame and the character returns to expected functionality for 122 updates.

I’ve tried everything I can think of to fix it:

  • Lowering the frame rate to 30 results in this happening every 63 frames.
  • Changing the value of gravity has no effect.
  • Changing physical scale doesn’t prevent this from happening.
  • If I remove player input this still happens.
  • Happens with both vsync on and off.
  • Happens in both fixed_update and update loop
  • Happens when physics “used fixed time stamp” is both on and off
  • Tried changing the collision shape

I am using a lot of code from Dragosha’s light and shadow example, but I do not think that is related: GitHub - Dragosha/defold-light-and-shadows: Pack of shaders to make light and shadows in Defold.

Any ideas for what can fix this?

How do you detect collision with the ground? Try using raycast with a vector with a small margin towards the ground instead of shape collision.

Is it possible to guess that it has something to do with garbage collector running periodically? You might also want to look at the frame duration via web profiler (Debug > web profiler), maybe it will clarify the issue.

I might be unrelated but I’m having similar issues with a go.animate where randomly it skips to the end of the destination. It is fairly a big jump but recording it and reproducing it is proving very difficult.

It’s like there is a big fluctuation happening at some point. This for me started with 1.8.0. Have you tried reverting back versions?

I’m using a capsule, I’ve tried with a box too but had the same thing happening.

I switched it over and it’s working correctly now! Thank you!

I’m using go.set in my project. I tried using go.animate a while back in my 2d games but had issues with phasing through walls. Maybe trying playing with Vsync, update frequency, and fixed update frequency some?

Go.set doesn’t work with collision boxes as you move it it can by pass the “check”. Sounds like raycast works though. I’ll need to start using that in the future. I wish they could fix collision boxes to work with go.set though.

I think you misunderstood it a bit.

go.set works fine with collision objects. It does however mess with the continuous collision detection (a.k.a “bullet”). For CCD to work, it needs to do continuous calculations, and that won’t work if you suddenly teleport the object to another place.
As mentioned to you before, to make use of CCD, you need to only use forces to act upon the object.
To help with your scenario though, there are (as mentioned) raycasts, and also shape casts. We haven’t implemented the shape cast yet, but we should put it on the short list for the next update of our Box2d Lua module.

1 Like

Correct you have to use force. You can’t use go. Set. Go. Set also fails when not using bullet as well.

BTW: I just found out it happens with force only as well. I kept adding collision boxes and spheres to try and make sure it wasn’t getting through a small section. But as you can see it still does. Also it will get lodged on the far right inside of the collion box.