Skip to content
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

Move bumper impulse into physics loop #491

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

arthurkehrwald
Copy link
Contributor

#483 added the impact of the bumper on the ball directly inside the BumperApi.OnCoil method. This PR moves the execution of that code into the physics loop using the PhysicsEngine.ScheduleAction function.

@arthurkehrwald arthurkehrwald mentioned this pull request Nov 11, 2024
@arthurkehrwald
Copy link
Contributor Author

I've added an ugly workaround to fix another issue with #483 I described in its thread. I added a flag called IsSwitchWiredToCoil to the BumperState struct that allows the physics engine to immediately push away balls that enter the bumper collider just like before, but only if the bumper switch is actually wired to the coil. I'm still not happy with this, because it's way more complicated than it should be and it also means that the impulse is almost applied twice: Once when the ball first enters the collider and then again when the coil is triggered by the bumper switch. The only reason this doesn't cause issues is because the ball is already pushed out of the collider by the time the second impulse is applied to all balls inside the collider. We do still need the second impulse though, because it is no longer guaranteed that the coil activation was caused by a ball hitting the bumper, since the game logic engine can activate the bumper coil whenever it wants.

@freezy
Copy link
Owner

freezy commented Nov 18, 2024

Okay, I'll review this the next days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants