How do I create realistic pinball physics explained

0 favourites
  • 10 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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.

    Here is the Demo:

    https://www.scirra.com/arcade/tutorial- ... 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 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 moveable 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.

    https://www.scirra.com/arcade/tutorial- ... demo-13984

    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.

    Enjoy and leave any questions and feedback in the comments!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Nice. You should add this in the tutorial section if you haven't already.

  • Nice. You should add this in the tutorial section if you haven't already.

    Thanks Burvey!

    I plan on doing that when I have my game finished and so I can explain other physics used like the variable speed plunger and tricks and special affects. Lots of goodies going in to this game/sandbox creation.

    I will include a simple CAPX with it when I get the time.

  • Sounds great. I'll be keeping my eye on the progress. Well done.

  • good template, really works good.

    but as usual, most of times, C2 physics brake the collisions due to the speed and step iteration.

    why i say that?

    every time i tried to create a C2 physic based game or tested physics none worked as good as expected, one issue that always happen, if the collision doesn't brake due to the speed, then the speed dumping will take a straight line instead of a gradually decreasing speed of the current angle and fall natural.

    bellow image shows the trajectory of c2 physics in no matter of what type of condition, it might get altered and minimized but is always going to be as the black line shows, which is always will try to find the shortest and straightest line instead of curving and slowing over time, as normal physics and real physics will do. it might get close to the green sometimes but will always brake if that happens. if its not the angular damping then is the speed iteration, and so on.

    edited:

    i found the r0j0hound's physics plugin (chipmunk) reacts much better, however it has some weirdly snags where it shakes on slow speeds.

    but your example still stands better then most examples of pinball, great job.

  • Sounds great. I'll be keeping my eye on the progress. Well done.

    I did put up a tutorial with the same info

    https://www.scirra.com/tutorials/9406/realistic-pinball-physics-with-demo

    I will get the CAPX and plunger done tomorrow.

  • good template, really works good.

    Thanks!

    I had that same issue and it drove me crazy.

    That was when I figured out the flipper was traveling too fast for collisions to be recognized. To fast for the human eye to see.

    I added in the Angular Velocity to the events to slow the flippers down and that eliminated the ball seeming to go through the flipper and the ball jumping off the point of the flipper.

    I also set all objects that create an angle that interferes with flipper collisions to have a small amount of Elasticity so ball is not coming in a straight line and that helps with collisions.

    Physics is a very strange world on a computer because of frame rates and how objects interact if they are close to each other even when not touching.

    Glad you liked the Demo and if you bookmark it I will be updating with more tricks as I go along.

    Oh and Merry Christmas and Happy Holidays!

  • Glad you liked the Demo and if you bookmark it I will be updating with more tricks as I go along.

    Oh and Merry Christmas and Happy Holidays!

    I shall, Merry Christmas to you too friend!

  • Hello Lamar, will this be available to download as a capx at some point?

  • Hello Lamar, will this be available to download as a capx at some point?

    Well, I haven't decided yet how to release it.

    I may keep it as a standalone sandbox designer you can use or provide a template with CAPX for people that want to buy my template and design their own pinball games.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)