- Home /
Using Configurable Joints to create Pinball Flippers?
So, for a while I have been trying different methods of making pinball flippers for my game. After a ton of trials and a some reading I am pretty sure that Configurable Joints will be the best way of making a pinball flipper. I know I have to set the target rotation and have the joint rotate to that point, but I'm not sure how since Quaternions confuse me. I was wondering if anyone could recommend a good way to use the joint to make it a flipper or how to set the target rotation.
Thanks
Answer by Peter G · Oct 06, 2010 at 02:43 AM
Configurable Joints are really overwhelming unless you are willing to go through and figure out what properties you need. My character in my current game uses them, and it took forever to actually set up the motion. If you do, then here would be the steps.
Set the rotation mode for y/z to position, and set the properties to be whatever speeds you want.
In your Script, you don't really need to know almost anything about Quaternions. Just use
Quaternion.AngleAxis(desiredRotation, Vector3.up);
Then use GetComponent to find your configurable joint and change the target rotation to that Quaternion and it will "flap" itself to that angle at the force your properties defined. You probably want world space (Use World Space [check]) so you might have to transform the rotation based on the flappers up direction. i.e.Transform.up
. Now, I always use world space, but you could use local space to as long as you account for rotating the object in the scene view.Then set the target rotation to
Quaternion.Identity
to reset your flapper.
Now, what I would do to save yourself a lot of time is to just use a hinge joint. Configurable joints are for when you have a specialized movement such as a complex character that is still physics controlled.
Hinge joints will let you specify a target rotation and the amount of force to move to it. Then, all's you have to change is the desired angle, no eulers or quaternions ore Vectors, just floats :).
And, given a flapper's movement is on a hinge, you would just end up spending extra time working out that behavior in a configurable joint.
Plus, hinge joints are easier to look at in the inspector. Configurable joints have so many properties that especially if you only use a few, you still have this blocky mass to go through when you want to tweak something. Which, all the properties have a useful purpose, but most objects will not use all of them at one time.
Answer by LS16BMX · Jan 03, 2012 at 11:44 PM
It might help to up your max angular velocity in the physics manager ! This will let your flipper flip much faster :O)
Answer by GeorgeRigato · Apr 20, 2011 at 08:02 PM
I'm doing the same pinball project, and trying to use Hinge Joints.
The issue i find is that the min and max angles do not limit the movement, they just act sort of gravity wells, dragging the object slowly to the position, causing a lot of bounciness (my bounciness config at the inspector are all Zero).
To move the flipper fast enough you have to apply a large force to the rigidbody, making the object to pass the max angle.
If anyone could just shed some light on a particular config that make the hinge joint behave like a real flipper would help.