1
\$\begingroup\$

When making pinball flippers in Unity C#, what would be the pros and cons of using a simple mesh transform -- where the mesh is properly centered around the wanted pivot, so its rigidbody could be torque force rotated -- vs creating the flipper with a joint? Thanks!

enter image description here

\$\endgroup\$
4
  • \$\begingroup\$ Which one makes more sense to you? Did you observe any unwanted outcomes when implementing it that way? \$\endgroup\$
    – DMGregory
    Mar 8, 2020 at 19:40
  • \$\begingroup\$ @DMGregory Guess I was looking for some battle lessons before I go down the rabbit hole of physics tuning (which will involve joint configuration, global physics settings, collider choice, physic materials, possibly even custom physics algos and so on). I'll report back should I have any interesting results. \$\endgroup\$ Mar 9, 2020 at 7:49
  • 1
    \$\begingroup\$ My general advice is to find a problem first before solving it. Here both options are at least plausible, so putting them to the test is the best way to find out if they work for your specific game's needs. \$\endgroup\$
    – DMGregory
    Mar 9, 2020 at 9:35
  • 1
    \$\begingroup\$ OT, but we're working on an open source pinball sim in Unity. See github.com/freezy/VisualPinball.Engine and vpforums.org/index.php?showtopic=43651 - contributions welcome :) \$\endgroup\$
    – phreezie
    Mar 11, 2020 at 12:27

1 Answer 1

1
\$\begingroup\$

Hinge joints with a spring and motor work well. hinge.useMotor is being turned on when Input.GetKeyDown(), and off when Input.GetKeyUp().

The Flipper joint settings, inspired by this asset:

Axis 0, 1, 0
Use Spring
    Spring 2
Motor
    Target Velocity 3000
    Force 100
Use Limits
    Max 55
    Bounce Min Velocity 0.2

And Project Time settings -- handle with care as it may affect framerate:

Fixed Timestep 0.002
Maximum Allowed Timestep 0.03333333

Flipper, ball and bumpers all have respective Physic Materials to lower friction and more.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Note that a fixed timestep of 0.002 means 500 physics steps per second. Depending on your target hardware, and the complexity of your physics scene, that might be excessive or start to impact your framerate and responsiveness. If you're targeting mobile, I might recommend staying closer to the default FixedUpdate rate of 50 steps per second (0.02 second fixed timestep) and see if you can compensate the physics via other means. \$\endgroup\$
    – DMGregory
    Mar 9, 2020 at 20:35
  • \$\begingroup\$ @DMGregory Good point, I edited my answer to add a warning, and will see how much higher I can tune it in my own case (the flipper-ball interaction was quite wonky using the default Timestep, so I used the values from the mentioned asset). \$\endgroup\$ Mar 10, 2020 at 7:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .