Gravity and disappearing object

I’m trying to create an object that bounces on a solid ground. The bouncy object is currently dynamic with a mass of 10 and a restitution of 0.9. The solid ground is static with a restitution of 0.8.

By default the gravity is set to -10 in the main game.project file, however when I change this I get a very strange behaviour. My bouncy object sometimes disappear when changing to for example -15, however sometimes it works. Also tried to change to -2000, same strange behaviour there, some builds works… some of them doesn’t.

Am I missing something here or what could be the problem?

Thanks

TL;DR: Dynamic object disappears when changing gravity. Why?

Not 100% sure here, but from what you’re describing it sounds like a bullet-through-paper problem - that’s pretty common in Box2D and other physics engine. It basically happens when an object is moving so fast a collision isn’t detected. This problem is often noticeable with small and fast moving objects colliding with thin objects.

In Box2D this is usually handled by turning Continuous Collision Detection (CCD) on for the simulation, or setting the isBullet property on the fast moving body (which tells Box2D to use CCD for that particular body). Not sure how this is handled in Defold, didn’t find any info in the docs.

Someone from the Defold team can probably answer this better

Yes, it sure sounds like a bullet-through-paper problem, and if I’m not mistaken we do not have support for CCD in Defold (even though the underlying physics engine is Box2D). I’m not sure what implications it would have to expose the bullet property. @sicher or @Ragnar_Svensson should be able to provide more details.

Try this first to get a better picture what’s happening:

/Ragnar

Thanks for all the replies! As it turns out it had nothing to do with gravity. The issue just seemed to occur when changing gravity, but in fact it was more like a random behaviour. However I’m sure there exist some explanation behind it.

The issue was that my background and my main character both had z=0 position. This resulted in on, what seems like, random builds the character object ended up behind the background. However in the editor, the character were always in front. Setting my character to a z=1 seemed to solve the issue. Is this an intended behaviour?

Objects at the same Z may be drawn in a different order, but it should not affect physics. How thick did you make your objects? Or where any of the objects in a collection with an offset position?