Pinball and paddles Physics

Hi! I'm trying to make a pinball game but I'm having problems to replicate correctly the "paddles throwing the ball" dynamic.

I found this old post with an example with the same identical problem that I am facing:
https://forums.tumult.com/t/discuss-pro-feature-physics/266/66

Basically the ball is thrown up and back by the paddle and not just up with a little inclination. It's really hard to play with this behavior.

This pinball is also made with Matter.js but doesn't seem to be affected by the same problem (only when the ball is very close to the pivot point):

It uses "magnets" to move the paddles, maybe that's the reason?

Any solutions for Hype?

Hype v4 has vector shapes that can work with physics; I would try changing the shape of the paddle to be curved. Note that the linked example uses a group as the physics body; you'd need the shape itself to rotate and be the body if you went with this approach.

And/or you may try having the final angle be a little bit less (and perhaps the initial angle a little more) -- there's probably some very specific physics that goes into pinball design :slight_smile:.

I already use vector shapes and the rotation to move them, I don't think the problem is there because I made several tests with the same results. :thinking:

image

You can just add the trapezoid through code. In the example you posted he does it with Matter.Bodies.trapezoid... Hype offers direct access to the Matter instance.

I believe is about the motion method and not about the shape: what's the proper way to control a body using Matter.js? He uses the matter-attractors plugin which makes everything more complicated...

This is why I created the Photics-Physics-Bridge.

https://photics.com/books/a-book-about-hype/photics-physics-bridge-ppb-js/

...as it makes it easier to control Physics bodies. I'm thinking maybe the paddles might work more like expected if Angular Motion was used. However, and this is just theoretical, there are problems...

I really want to make a pinball game with Hype, but I'm busy with the book project right now. I thought Tumult solved this problem though. The promo video for Hype 3 showed a pinball game.

Notice how they're just rectangles? Perhaps that's the real problem. Maybe just use a simpler shape. The collision shape doesn't have to match the graphics perfectly. Just look at Street Fighter...

https://photics.com/hit-boxes-using-rectangles-to-make-complex-shapes/

Awesome, thanks for this library, makes things easier! :slight_smile:

I already tried to used rectangles as paddles (I made several tests using what Hype provides before writing) and I think the solutions is adding some magic code in order to comunicate better what's going on to Matter.js.

However in the video it seems working well, @jonathan do you have that pinball example to share?

I'm not sure how well it specifically works as a pinball game since it was just a demo document, but you can grab it here:

download
live

1 Like

This definitely helped: I was wrong, it's about the shape, in the sense it must be longer! Having the center point turning is different than having the side turning, for some mysterious reason. :sweat_smile:

Grouping the paddle shape, in order to extend it's length, works! Of course the group must be Static.

2 Likes

Oh, I'm glad you figured it out! Taking another look at my original document, I did it that way... It was so long ago I don't remember why, but perhaps that was the part of the reason!

This is my attempt of a pinball game using just the hype shapes and the physics engine, I really like the result but there are moments where the ball moves really strange and if the game restarts the ball moves a little bit quicker.

http://c1ic.mx/pinball/

I hope you enjoy it!

3 Likes

Wow, that works really well and is fun to play!