Realistic Pinball Physics With Demo
Ok so I have been pulling my hair out for a month working on a realistic pinball sandbox game that will allow users to design their own pinball games and share them with their friends.
The problems have been many and examples in tutorials suck because there are many factors such as size of collision box and objects in vicinity of a ball that affects physics.
I finally got the settings right for my game and the paddles have a very realistic feel and you can stall the ball, dribble the ball, pass the ball from one flipper to the other just like in a real pinball game.
Demo:
https://www.scirra.com/arcade/tutorial-games/pinball-physics-demo-13984
Here are the settings I use however like I said there are many factors that will affect physics so you may need to adjust settings and change the collision box and impulse points for your specific game but this is the way it works.
First create a ball sprite and set the collision box to object:
Then set the ball physics:
Then create a paddle with a collision box set to the paddle object and two points for joints and impulse.
Paddle origin point:
Paddle Hinge (revolute joint) point:
Paddle impulse point:
Set the paddle physics.
Create a sprite box to anchor the flippers to and keep it small and center the origin point.
Physics setting for joint box:
Now place your joint box and flippers on your layout where you want them to appear. The flippers will automatically attach to the joint box origin point after we set the events and run the game.
create some outside boundaries so the ball bounces off the walls:
Just use a filled box for a sprite and and set the physics.
Create a bumper bell object. A filled circle with centered origin point and set the physics.
NOTICE: the Elasticity is set to 1 or higher for objects you want the ball to bounce off of at a faster speed.
REMEMBER- everything in a game using physics must have a physics behavior to interact or strange and terrible things will happen.
Your objects should look something like this now.
Now here are the events:
Run the layout and if you did everything correctly you should be able to control the flippers very accurately with the arrow keys. If objects are falling down it is because you didn't set them to immovable. Only the paddle and ball is movable and allowed to rotate.
That is the exact events and settings used in my game design below and I am just using fancy graphics and some whiz bangs and special affects but the physics are pretty simple once you understand how objects in the real world react with other objects.
Bookmark my Demo and you can watch as I progress on the game and I will update with how to make a variable speed ball plunger later.
Demo:
https://www.scirra.com/arcade/tutorial-games/pinball-physics-demo-13984
Enjoy and leave any questions and feedback in the comments!