+2 votes

Hello Godot Community,
I'm trying to implement a 3D Pinball game and I'm struggling with the physics engine in order to archieve the relatable ball behaviour.

My Setup:
As sandbox, I build a quick and dirty pinball table from build in shapes.
Mostly stretched cubes as static bodies to make to floor and the walls of the table.

Pinball Table

The walls are static bodies with appropriate collision shapes.

There are also some wedge meshes used as "reflectors" with collision shapes made with the "create convex collision sibling" function which are static bodies.

My ball is a rigid body sphere with matching collision shape.

The flippers are kinematic bodies, made from a model created in and imported from blender.
I used the "create convex collision sibling" function to create the collision shapes.

The launcher is also a kinematic body with a simple cube mesh and collision shape.
I animated it with an animation player to launch the ball.

My Control:
I to start the ball I simply start the animation of the launcher, which works well enough for now.

The flippers are controlled via the analog triggers of my X Box Game Controller.
I use the SetRotation function to rotate the flippers according to the ActionStrength of my triggers.

My Issue:
When the ball hits the flippers it sometimes moves as intended, but its kind of glitchy.

The amount of forces the ball receives is not really relatable, small moves may shoot the ball quite fast away, while sometimes a fast flipper movement causes the ball to glitch through the flippers, or does not interact at all.

I tried to increase the physics fps, but it just prevents the ball from shooting out of the top of the table when it "got hit to hard", which fixes this at least.

I also tried using static bodes for the flippers with neglectable results, so I reverted to kinematic bodies.

My Question:
It's just an prove of concept to get the mechanics straight so no fancy graphics for now.

But is there a fundamental flaw in the design?
What would be a better solution to build a nice and exciting pinball game?

in Engine by (23 points)

1 Answer

+1 vote
Best answer

I figured it out:
By further playing with godot, I solved a good deal of my glitches.

First I tried out the bullet physics engine, which made things better.
But I it was not perfect.
Furthermore I figured my raw inputs caused some trouble.
I initially used the "_Input" Methode to handle the inputs.
Now I moved this code to the _PhysicsProcess function.
I also added a lerp function to rotate the pedals, to add an continous motion.
Applying a lerp to the rise and fall of the flippers solved any issues I ran into.

My lession here: The physics engine likes continuity. High frequent changes of analogue inputs or instant motion will cause the glitches. This might be good lession to take away when working with physics engines in general.

by (23 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.