I’ve looked up how to do pinball flippers. From my research…
Some have suggested using hinge joints. However I can’t get the flipper to be stationary or not move so this isn’t feasible for a pinball flipper as pinball flippers aren’t supposed to have any give from contact with the ball.
Some have suggested using configurable joints. However the documentation on how to properly use this feature or what this feature is even intended for seems quite vague. As most of the information I have dug up on configurable joints show how to rig something for ball and chain type rigs which isn’t anything close to what I want.
I can’t help but think maybe I should just try to fake it by applying a force to the ball when in the vicinity of a flipper that is going through a swatting motion.
I’m very new to the physics. I haven’t done this, but just an idea you might want to try.
Make an animation for your flipper object. Make sure it also has a collider and all that physics stuff. Set it to kinematic I think… And then add a script that says when input whatever - then play animation, the physics should work together?
hinge joints and motors are what I used in my pinball game.
With this setup there is a limit to the “targetVelocity” in relation to the mass of the rigedbody. If you go over this limit the joint becomes erratic jumping the whole time but if you are below this breaking limit it works perfectly.
I cant say what the relation between the mass and this force is … I just tested it by trial and error and watched the transform inspectors values to make sure the rotational values came to a stand still after each use of the motor.
You can download my game for android ( link in my sig ) or view it in your browser here :
I should also mention you need to use capsule colliders for the flipper collision object if you want to use continuous dynamic algorithm on the ball and flippers. Continuous dynamic only supports primitive colliders.
I would’ve said that using a pre-built physics solution for a game where the physics IS the gameplay (like pinball) is a bad idea,
You can’t really expect to plug in an all-purpose middleware physics sim like physX or havok (which are great for effects), and expect it to give a good realistic feel that some of the ‘popular’ pinball titles have (which I expect have purpose-built physics for the gameplay)
But shaderbytes game feels pretty good, so I might have to have another go at getting it right (What scale are you working at? ie is the ball actually 0.027 units (1 1/16 inches standard ball size) or are you working with everything bigger)
Im very sure zen pinball and other top pinball production studios have custom physics solutions as you mention.
Everything in my game is super size big eg… I think the ball was 0.48 unity units, so that is like just under half a meter! (diameter) I was of the mind set that working with extremely small objects would be subject to more floating point errors ? not sure about that ?
My Gravity was about 150 or 170 and table slope about 5 degrees
The reason why I’m interested in this. I tried out zen pinball and then I tried out The Pinball Arcade on steam. (it’s free to try out) And I couldn’t help but feel the ball movement was a bit sluggish. Especially when I compared the real tables like Attack from Mars and Funhouse to the simulated version in The pinball arcade. The ball felt sluggish and the ball felt glued to the table and didn’t have the ability to be kicked up off the table when hitting a pop bumper.
Wow, nice game!!!
I’m also trying to maka a pinball but i’m stucked at the flippers!!! I used hingejoint and motor but when the ball is held by the flipper, the flipper stills adds force to ball and it makes it bump. Video
wow that game of mine is old now hehe , do you have a gaming pc? you can try my latest table , its a recreation of a real life table and also uses proper rom emulation :
you didnt mention what version of unity you are using? The thing is its tricky to say what values to use because the scale of the objects and their mass all play a part. Have you set physics layers up for your collisions , I do this in my tables so objects like flippers and table surface are all on one physics layer which I then set to not collide with themselves… they only collide with the balls which are on a different physics layer.
@Danicano I just looked at your video again … your flippers joint is moving when you use the flipper , look carefully, when your flipper rotates it is not rotating perfectly around a point … it shifts position. I’m sure this would be playing a part as to why your flipper is not remaining stable…
Hi. Thanks for answering!!! Sorry for my late answer !!!I’m now using 5.3.4f1!!!
Wow. You are right! My flippers don`t rotate perfectly!!! I’ll work on that and I’ll report!!!
Thank you very much.
I tried your Elvis pinball and I think you’ve made an awesome job!
Whish I have your skills!
I’m struggling with the “perfect” rotation around a point and I can’t get it. Wherever I put the joint, when a important force or speed is applied, the joint goes a little “mad”…
How are your setting up the joint ? In the inspector or are you building it at runtime?
How are you moving the joint , via the joint motor force property?
Have you increrased your rigidbody maxAngularVelocity enough?
Did you make sure the flipper is not colliding with the playfield , did you set up physics layers and exclude collisions on the same layer as I mentioned before?
I also set my axis manually but that is to control rotation direction and depends on the specific orientation , so yours might not be the same as mine, just letting you know
Wow. Lots of information here.
I’m setting up the joint via inspector
The joint moves via motor
I tried to increase maxAngularVelocity to 10? (the manual says the default is 7 )
I followed your advise and made a layer for non collision objects.
HingeJoint hinge;
JointMotor motor;
public KeyCode myKey;
void Start(){
GetComponent<Rigidbody>().maxAngularVelocity =10f;
}
void Update () {
if (Input.GetKeyDown(myKey) || Input.GetKeyUp(myKey)){
HingeJoint hinge = GetComponent<HingeJoint>();
JointMotor motor = hinge.motor;
motor.targetVelocity = -motor.targetVelocity;
hinge.motor = motor;
}
}
I simply turn the velocity of the motor a negative value to move the flipper…
But after struggilng with settings, I realized that the bounciness threshold was 1 and I set it to 2, and violà!, with this setting and adjusting the flippers bounciness (via material) I’ve managed the ball to stay still.
But all your advises are a huge help to me. Thanks for that!!!
Now I will going on and try it make it work like I wish, playing with all settings…
@Danicano look at my previous posts , I made mention that you need to use a capsule collider on the flippers. This is because only primitive shapes support “continuous dynamic” collisions , which is what you need. Also the ball is a primitive collider so make sure you have set continuous dynamic on this as well.