Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

To expand on @teriyakisaurus’s answer, it’s actually a bit of a mix! The ball is the only `RigidBody2D` in the game. The two bumper types (circular pylon and flat bumper) are `StaticBody2D` objects and use `apply_impulse` to give an instant kick (they were @doublea999’s work). The flipper is an `AnimatableBody2D` and uses the normal Godot physics to hit the ball (it uses an `Area2D` to decide when to flip, but actually affecting the ball’s motion is done directly by Godot collision physics). Finally, the launch plunger is actually a mixture: initially (where the ball bounces and lands on top and then descends gradually as the plunger is pulled out) it’s an `AnimatableBody2D` with the ball sitting on top, but to actually fire, that worked too inconsistently, so I instead use `apply_impulse` and then move the `AnimatableBody2D` back to its original location a few seconds later.

Yeah, we also used a RigidBody2D for the ball and StaticBody2D for the bumpers. But the bounce effect was done in our case by changing a "bounce" value in the graphical interface on the bumpers objects.

The way you coded an impulse whose direction depends on the angle of the ball creates a much better effect!

I considered using the “bounce” property for some of the physics, but rejected it because, if I understand correctly, a bouncy object means the ball would bounce back harder the harder it hits, whereas pinball bumpers have their own power source, so they should really push the ball away with equal force no matter how fast or slowly it’s going when it arrives. Hence the idea of using impulse instead.

Yes I can clearly see what you're saying and from the gameplay of your game I can also see that it was the right call.