I have a dynamic ball bouncing on a static surface. The ball overlaps the surface for one frame, before bouncing up. How can this be avoided? I use the Orthographic camera.
Edit: This only seems to happen when the surface is using a built in Box Shape. When a Collision Shape is used I haven’t been able to replicate it.
Having continued my game I get this behaviour on all shapes most of the time. Is there a way to avoid this one frame “tunneling” of dynamic objects?
It’s not a game breaker, but it’s noticeable when the camera follows an object that burrows into solid objects for one frame. Can I force a graphic update at the same time as the physics is updated somehow?
I believe, this is how physics works with a such high gravity. Continuous Collision Detection (making ball a bullet) may fix this, but this is not accessible in Defold.
That might be true, although I’ve never seen this before as I’ve never had gravity set to so high. Is there an alternative way to make things move naturally? With the default settings all objects added appear planet sized and move very slowly.
In game.project under Physics you can set the scale of the physics simulation. I think Box2D maps 1 pixel to 1 meter in its simulation, so setting the scale to e.g. 0.02 would map 50 pixels to 1 meter instead.
There is an ongoing feature we are developing to decouple the physics simulation from the game loop, allowing you to run the physics at a higher (or lower) rate. It’s not prioritised in our backlog yet and still early in development: Teaser Fridays and Roadmap talks - #89 by Johan_Beck-Noren
Being able to run physics at a higher rate should make the overlap smaller and not as noticeable.
This has turned into a bit of a problem now, as the ball in my game actually gets stuck within the terrain. I’ve spent all morning trying to solve it, without success. Here’s what I’ve tried so far:
Adjust gravity and scale
Limit the velocity by adding linear damping
Cap the velocity programmatically, by reading linear velocity and send a counter impulse to stop the ball going too fast
Add a trigger to detect a collision and slam on the brakes with impulses
If you are trying to “fix” the dynamic physics simulation by modifying linear velocity etc. you might be better off using a kinematic collision object and handle the simulation and collisions yourself instead. That way you get more explicit control of how the collision objects behave.
If -10 is “natural gravity”, how do I create a dynamic body football bouncing naturally? No matter what settings I use, I seem to end up with a football that moves much, much too slowly for it to feel “natural”.
Has someone done this and can point me in the right direction?
Yes, those values appear more natural. BUT they have the issue of tunneling, which I’m trying to avoid by being a good boy and following all the rules.
I noticed that! But it still says -10 is “natural”, but I think that may be natural only on a small comet.