How do I create realistic pinball physics explained

Get help using Construct 2

Post » Wed Dec 28, 2016 4:21 am

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:

Image

Then set the ball physics:

Image

Then create a paddle with a collision box set to the paddle object and two points for joints and impulse.

Image

Paddle origin point:

Image

Paddle Hinge point:

Image

Paddle impulse point:

Image

Set the paddle physics.

Image

Create a sprite box to anchor the flippers to and keep it small and center the origin point.

Image

Physics setting for joint box:

Image

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.

Image

Create a bumper bell object. A filled circle with centered origin point and set the physics.

Image

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.

Image


Now here are the events:

Image

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!
Last edited by lamar on Wed Dec 28, 2016 4:35 am, edited 1 time in total.
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Wed Dec 28, 2016 4:23 am

Nice. You should add this in the tutorial section if you haven't already.
B
60
S
20
G
56
Posts: 1,077
Reputation: 35,941

Post » Wed Dec 28, 2016 4:34 am

Burvey wrote: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.
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Wed Dec 28, 2016 4:39 am

Sounds great. I'll be keeping my eye on the progress. Well done.
B
60
S
20
G
56
Posts: 1,077
Reputation: 35,941

Post » Wed Dec 28, 2016 4:46 am

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: Image


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.
B
71
S
20
G
67
Posts: 1,317
Reputation: 42,332

Post » Wed Dec 28, 2016 5:03 am

Burvey wrote: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.
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Wed Dec 28, 2016 5:10 am

gamecorpstudio wrote: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!
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Wed Dec 28, 2016 5:39 am

lamar wrote:
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!
B
71
S
20
G
67
Posts: 1,317
Reputation: 42,332

Post » Sun Feb 26, 2017 3:09 pm

Hello Lamar, will this be available to download as a capx at some point?
B
14
S
5
G
1
Posts: 25
Reputation: 1,541

Post » Sun Feb 26, 2017 3:34 pm

polygame wrote: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.
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540


Return to How do I....?

Who is online

Users browsing this forum: Sparkz and 1 guest