godot-demo-projects icon indicating copy to clipboard operation
godot-demo-projects copied to clipboard

Bullet shower bug at low tick rate

Open lawnjelly opened this issue 3 years ago • 1 comments

Which demo project is affected: Bullet shower

OS/device including version: Any

Issue description: This is a bug found by @aaronfranke , I'm just reporting here in case the solution got missed on rocket chat.

aaronfranke : I found a bug in the Bullet Shower demo. If you set the physics FPS to 10 and move the mouse around the dots in a circle quickly enough, then the "touching" variable gets stuck at 0. I tested this with and without demos#595 and it occurs on both. Is there some kind of desync going on? I've tried to fiddle around with it to find a work-around (including by delaying mouse input until the next physics frame), but nothing seems to work.

@pouleyKetchoupp investigated, these were the results:

aaronfranke lawnjelly I was checking the bullet shower demo and found what happens with the bug you found (the area stops detecting bodies after some time with physics fps 10). It's due to gravity still being applied to bullets each frame, which builds up over time. Their position is being set every frame, but in the physics simulation, they are moved down at the end of each step due to large gravity force and it's causing them to be unregistered from the area. As a workaround, you can either reset their velocity each frame after setting their position, or set their gravity scale to 0 so they are not in free fall. Later I'll probably make a change in the physics servers to reset velocities when you set a physics body transform, but I need to spend more time testing before doing such a fix since it could affect other use cases.

We weren't sure whether doing this automatically in physics was a good idea, so the best fix for the demo would probably be as Pouley suggests, to either set gravity to 0.0 or to reset velocity after each move.

lawnjelly avatar Mar 17 '21 08:03 lawnjelly

I updated this demo to 4.0-dev and I could not replicate this issue. Probably fixed because of the new Godot version?

voylin avatar Apr 02 '22 23:04 voylin