How to make a pinball "bumper"

I tried just giving the bumper object a large “bounce” value, but that doesn’t really work. If the ball is moving slowly when it hits the bumper, it won’t bounce much even if the bumper has a high “bounce” property.

What I need is an object that, when touched, applies a certain set force to the object that collided with it. This force should override the original collision force. Has anyone tried to do something similar? I’m thinking this should happen in the preCollision handler.

I’m stuck on the following:

a) how to cancel the original collision in the preCollision handler

b) how to apply a force to the object that hit the bumper in a way that looks natural - it needs to bounce off at the correct angle as it normally would, but with a constant force applied to it, as a pinball would bounce off a bumper. [import]uid: 52127 topic_id: 10280 reply_id: 310280[/import]

I think you should apply a force as I have in my draggable fan demo, except using the applyLinearImpulse function.

Tbh, the hard bit is working out the x,y values to use in applying the force value and the values to apply, but this is definitely what you want.

My posts about tests on this subject:
https://developer.anscamobile.com/forum/2011/05/04/how-simulate-wind
https://developer.anscamobile.com/forum/2010/10/21/simple-draggable-fan-demo [import]uid: 8271 topic_id: 10280 reply_id: 37514[/import]

I have been experimenting with building a pinball game. I have a basic playfield programmed with a bumper, slingshot and flipper. There is no scoring and no sound. This is just to test out the physics, mainly that of the flipper and ball collisions.

I believe that I have the flipper and ball collisions working satisfactory. You are invited to inspect and use my code. You can download it here:

http://martinapps.com/files/pinball physics.zip

My thanks to Jonathan Beebe for his tip about waiting to do the processing associated with a collision event. I’m using the runtime “enterframe” event instead of the timer.performWithDelay that he used. Search for this statement in my code: Runtime:addEventListener( “enterFrame”, doCollision ) [import]uid: 23636 topic_id: 10280 reply_id: 38755[/import]

http://martinapps.com/files/pinball%20physics.zip
Fixed that for you :slight_smile: [import]uid: 10389 topic_id: 10280 reply_id: 38884[/import]