Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Scale and Force Unwated Results

Discussion in 'Physics' started by renman3000, Jul 12, 2023.

  1. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,681
    Hi,
    So I have recently become aware of the potential for the scale of an object to affect the physics of that object. In other words, the further the scale is from Vector3.one, the greater potential for erratic behaviour when using addFroce(), at least this seems to be my experience.

    What I am hoping for is suggestions for better results.
    I have a class of object called co, which uses AddForceAtPosition().
    When an instance of co goes below the threshold scale it begins to move differently.

    Does anyone have any suggestions on how to mitigate this?
    Thanks!
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,428
    Yes, scale does affect the physics of a Rigidbody, even if you carefully consider the scale when applying your forces to scaled positions.

    The reason is the inertia tensor of the Rigidbody (Rigidbody.inertiaTensor and Rigidbody.inertiaTensorRotation). Inertia is the rotational equivalent for mass. In physics the inertia tensor is typically defined with a 3x3 matrix, but in Unity / PhysX this is reduced to a Vector3 and a Quaternion. The more inertia, the more force is required at the same position to produce a given angular velocity.

    By default, Unity calculates the inertia tensor combining the position, shape and dimension of all the colliders that belong to the Rigidbody. Therefore the larger dimensions, larger inertia and potentially different distribution of inertia.

    A possible method to preserve the same physics behavior at different scales could be:
    1. Leave Unity to compute the inertia of the Rigidbody at scale 1:1.
    2. Write the inertia tensor to itself. This disables the automatic recalculation of the inertia tensor: rb.inertiaTensor = rb.inertiaTensor.
    3. Apply the scale to the object.
    I haven't tested this method though, so I can't tell if/how it works.
     
  3. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,681
    @Edy
    Thanks.
    So I just wanted to follow up as i have found a solution.

    In my case, I am using 3D models, pulled into the scene. Since I have access to the Model itself, I can access it's Import Settings, specifically Scale Factor!!!!

    This is key, as I can now scale the model down by whatever factor I want. Now when I pull the object into the scene, at scale 1, it is teeny tiny. So if I scale it up to what it normally would be, the transform scale (in my case ) sits at 1000!

    This is perfect because now when I shrink it down in the game, its transform scale is at a very manageable level.


    SOLVED!