modeling a pinball flipper (pymunk) / was Re: trouble with [

Official forum for the Chipmunk2D Physics Library.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: modeling a pinball flipper (pymunk) / was Re: trouble with [

Post by slembcke »

It's expressed in radians per second (or rather radians / seconds).

Without dividing by the time to move that distance, it was simply a distance.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
viblo
Posts: 206
Joined: Tue Aug 21, 2007 3:12 pm
Contact:

Re: modeling a pinball flipper / was Re: trouble with [...]

Post by viblo »

beeduul wrote:Hi guys, thanks for following up. I got sidelined and am just getting back to this project.

slembcke, I created a manually controlled flipper like you suggested in the other thread @ viewtopic.php?f=1&t=787. The control is great, but I get a lot of 'stickiness' -- the ball tends to grip to the flipper instead of being hoisted up. Note, friction is set to 0 and elasticity to .95 for both the flipper and the ball (I figured I'd start conservative and tune down.) Do I have to impart forces manually upon collision in order to 'whack' the ball with the flipper? Sorry, I am still fumbling my way through chipmunk & game physics simulations in general.

viblo, your pastebin link is no longer working. I'd love to see your code. Do you still have it around?

thanksthanks
Its actually included in the examples folder of the pymunk source distribution: http://code.google.com/p/pymunk/source/ ... flipper.py

However, now that I tested your manual move code it feels much less sluggish so you probably want to stick with that, at least the real simulated flippers method needs more tweaking to behave as good (depending on how you want it to feel).
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
samtny
Posts: 6
Joined: Fri Mar 25, 2011 11:48 am
Contact:

Re: modeling a pinball flipper (pymunk) / was Re: trouble with [

Post by samtny »

Old thread, but if anyone is still interested in modeling a pinball flipper using Chipmunk Physics, I managed to get excellent results, without overriding the Chipmunk movement code, by doing the following;

1) Create a body with very high mass (relative to the pinball) and a "cpMomentForCircle" that is about twice the radius of the pinball
2) Position the body at the pivot point of your flipper
3) Attach a Circle shape to the body that is the appropriate size for the base radius of your flipper
4) Apply a pivot constraint to the center of the Circle shape
5) Apply an angular limit constraint to the Circle shape of about 45 degrees, or whatever you would like the "sweep" of your flipper to be
6) Attach a Segment shape to the body in the position and direction you would like your flipper to point

Finally, to "flip" the flipper;
1) Apply a large impulse to the body (base of the flipper), at an OFFSET equal to about twice the radius of the flipper base
2) Simultaneously apply the identical impulse to the OTHER SIDE of the body, but in the REVERSE direction of the first impulse

This will make the base of the flipper rotate smoothly and...

...flip!

However the flipper will not stay flipped unless you also apply a FORCE to keep it up, so;
1) Apply a medium force to the body in the same manner as impulse #1
2) Apply a medium "reverse" force to the body in the same manner as impulse #2

Hooray! This is a close approximation of how a flipper works "in real life", so it is perhaps unsurprising that it works well in simulation.

The reason the body has high mass is to counteract the force of the ball when it strikes the upraised flipper.

-S
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests