-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ball escapes arena in breakout example #1240
Comments
Reproduced on Chrome as well :) |
I tried 2 different ways of fixing this. I tested them both by running Valheim in the background and setting breakout to only use 1 logical core. On main the ball would escape, but both solutions stopped it from happening. I'm not sure which would be better. It depends on what this example is trying to demonstrate. Using a Fixed Timestep Using a different colliding calc for the walls So the first method adds a dependency on FixedTimestep and removes any dependency on Time. So if the example was supposed to show time dependent velocity collisions, this probably doesn't make sense and using FixedTimestep might not be considered idiomatic. The second method added an event system and some custom collision logic. I think this ends up making the example a little more complex, which might be bad since I think the breakout example is supposed to look pretty simple. |
IMO the @hymm can you open a PR with the |
This PR fixes bevyengine#1240, where the ball is escaping the playing field at low framerates. I did this by moving the movement and physics system into a Fixed Timestep system set and changing the movement steps to a constant. So we lose the example use of delta_time for changing position, but gain a use of FixedTimestep. If this is accepted bevyengine/bevy-website#102 will need to be updated to match. Co-authored-by: Carter Anderson <mcanders1@gmail.com>
This PR fixes bevyengine#1240, where the ball is escaping the playing field at low framerates. I did this by moving the movement and physics system into a Fixed Timestep system set and changing the movement steps to a constant. So we lose the example use of delta_time for changing position, but gain a use of FixedTimestep. If this is accepted bevyengine/bevy-website#102 will need to be updated to match. Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Bevy version
master
Operating system & version
Windows 10 / web
What you did
Just let it run for a while.
What you expected to happen
Ball stays in the arena.
What actually happened
Ball escapes the arena.
Additional information
There are three scenarios where this can happen (for each direction). Example below given for ball travelling downward.
https://github.com/bevyengine/bevy/blob/master/crates/bevy_sprite/src/collide_aabb.rs#L32-L40
I suspect that at lower frame rates (or fluctuating timesteps) + high ball velocity, the ball "teleports" greater distances between frames so this can happen more often.
There is also an additional scenario where the ball can collide with two walls at once, but because we break out of the collision detection loop when
Collider::Solid = *collider
, it bounces off one wall into the other (and then next frame you get one of the scenarios above).The simplest fix to the example would be to make the wall thickness thicker (at least as thick as the ball), but it doesn't really address the collision detection (which I understand is just a temporary thing).
Some code (and screenshots) to see what collisions are happening: https://gist.github.com/tigregalis/fcf99c587134f382c16ab42edc64af1c
The text was updated successfully, but these errors were encountered: