Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Sphere physics for small scale objects - Like a golf ball

Discussion in 'Physics' started by nunesbarbosa, Nov 1, 2017.

  1. nunesbarbosa

    nunesbarbosa

    Joined:
    Jul 17, 2012
    Posts:
    103


    Guys, I'm developing a golf game with real scale. But physics does not behave the same way on smaller scales.

    I've applied the same thrust and torque on the 3 balls. The only difference is the scale: 1x, 0.1x and 0.01x.

    All spheres should have the same behavior, right, so why only the larger sphere behaves the way it should? The terrain and spheres have maximum friction, so why do they never get to attriction and keeps spinning?

    I've considered scaling everything by 100x but it is messes the physics and game logic even more. Ideas?
     
  2. KeithKong

    KeithKong

    Joined:
    May 31, 2015
    Posts:
    73
    Don't actually "scale" the transforms. Rigidbodies do not like to be scaled. Simply scale the mesh in a child game object (or better make the mesh the right scale to begin with). Then change the radius on the SphereCollider itself.
     
    jmarsh411 likes this.
  3. nunesbarbosa

    nunesbarbosa

    Joined:
    Jul 17, 2012
    Posts:
    103
    As far as my tests go this is not a rigidbody scale issue but a Sphere Collider radius issue. I've worked on a custom mesh for a 1x1x1 scale but the effects are the same. I can't use Mesh Collider unforunatelly.. :(
     
  4. KeithKong

    KeithKong

    Joined:
    May 31, 2015
    Posts:
    73
    You're experiencing a combination of problems in unison I think.

    First, the video you've shared shows the transform has been scaled. The mesh itself doesn't really matter, I only mentioned fixing the mesh scale because it's technically more efficient. What's important is that the transform your Rigidbody/Collider is attached to needs to be (1,1,1) and then adjust the Sphere Collider radius to change the collision size.

    Second, you may be experiencing a problem with fast moving small objects. Try setting the rigid body collision mode to ContinuousDynamic.

    That being said, very small objects may still have strange behavior. But I don't think you should be experiencing this at the 0.1 scale (maybe the 0.01 scale).
     
  5. nunesbarbosa

    nunesbarbosa

    Joined:
    Jul 17, 2012
    Posts:
    103
    I've tried all this before posting here.
     
  6. KeithKong

    KeithKong

    Joined:
    May 31, 2015
    Posts:
    73
    You might just be hitting the limits of PhysX in that case. You can try messing with the Fixed time step to see if increasing it makes anything better. Or try increasing the mass. PhysX does have it's limitations due to favoring efficiency over range (in terms of mass, scale, and distance).
     
  7. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,967
    Do not scale rigidbodies. Scale the mesh.
     
  8. nat42

    nat42

    Joined:
    Jun 10, 2017
    Posts:
    353
    Thrust and torque are forces right? So they what accelerate the bodies in inversely portion to their mass (which PhysX prob basses on size and density or something?)

    So you have a rocket engine hat you use to impart thurst on an Elephant, just enough to push it along at a human walking pace, now you swap out the elephant for a mouse and after refueling the rocket, wait where did the mouse go?
     
  9. KeithKong

    KeithKong

    Joined:
    May 31, 2015
    Posts:
    73
    nat42 makes a good point. I was assuming that by "same thrust and torque" you meant you were using ForceMode.VelocityChange for those methods. If not, try your experiments with that change.
     
  10. nunesbarbosa

    nunesbarbosa

    Joined:
    Jul 17, 2012
    Posts:
    103
    Physics behaves weirdly on small scales. I've made a 1x1x1 scale mesh (no scaling) with a 0.005 radius sphere collider. So I'm assuming all calculations are based in the collider radius related to object scale.

    The only thing that made it work was to set rigidbody.maxAngularVelocity to an absurd value like 50000 (why?!). Then the ball started to roll back as expected.
     
  11. KeithKong

    KeithKong

    Joined:
    May 31, 2015
    Posts:
    73
    Probably because small objects tend to generate a lot more spin when colliding with surfaces (or if you're applying the same torque versus a larger mass). rigidbody.maxAngularVelocity is not a physically realistic property. It specifically limits realistic spinning for the sake of keeping objects in a controllable range. So with something like a golf ball it's probably altering the angular velocity so much that the end linear behavior is also noticeably different.