I'm trying to simulate a flipper on a pinball machine.
I originally tried using a dynamic body for the flipper and a RevoluteJoint, but I was getting a lot of tunneling due to the high (and opposite) relative speeds of the ball and the flipper.
I got much better results using a kinematic body for the flipper, but limiting the flipper's upper and lower angles has proven difficult. If I simply set the angular velocity to 0 when it reaches the max angle, it'll stop a non-constant bit past the desired spot. If I use setTransform() to reset it to the desired spot, I get a one-frame "bouncing" effect, plus it severely messes with the physics of the ball if it happens to be in contact during that one frame. What would be the best way of putting a hard limit on the angular motion of a kinematic body?
Unfortunately, I'm using a native-compiled version of box2d for Java with a thin Java wrapper (AndEngine is that wrapper, in case anyone's heard of it), so I don't currently have access to the guts of box2d. If I did, I'd be in there hacking away and not bothering you all!
Thanks in advance!
I originally tried using a dynamic body for the flipper and a RevoluteJoint, but I was getting a lot of tunneling due to the high (and opposite) relative speeds of the ball and the flipper.
I got much better results using a kinematic body for the flipper, but limiting the flipper's upper and lower angles has proven difficult. If I simply set the angular velocity to 0 when it reaches the max angle, it'll stop a non-constant bit past the desired spot. If I use setTransform() to reset it to the desired spot, I get a one-frame "bouncing" effect, plus it severely messes with the physics of the ball if it happens to be in contact during that one frame. What would be the best way of putting a hard limit on the angular motion of a kinematic body?
Unfortunately, I'm using a native-compiled version of box2d for Java with a thin Java wrapper (AndEngine is that wrapper, in case anyone's heard of it), so I don't currently have access to the guts of box2d. If I did, I'd be in there hacking away and not bothering you all!
Thanks in advance!