Search Unity

Even with frictionless material and freezeRotation, rigidbody drifts after touching corner of room

Discussion in 'Physics' started by tscizzle, Sep 2, 2019.

  1. tscizzle

    tscizzle

    Joined:
    Sep 2, 2019
    Posts:
    5
    I have a Sphere moving around inside a cubic room. I use rb.MovePosition to move it from keyboard presses, the walls are typical Cube objects with Box Collider.

    I checked freezeRotation for all 3 axes, and my Sphere has a Physic Material with 0 friction.

    When I move the Sphere to the very corner, so it touches all 3 surfaces at once, it gains some drift, i.e. when I'm not pressing anything, it moves slowly in a single axis.

    My code/setup is so simple, I'm guessing this corner-case has happened to others before. Any ideas?
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,512
    Using MovePosition in non-kinematic objects is not a good idea. Both you and the physics are interfering each other tring to impose the object's position. You should use AddForce in non-kinematic bodies.

    As for your issue, bounces are also affected by the value Bounce Threshold in the Physics settings (Edy > Project Settings > Physics). Setting it to zero should ensure the sphere always bounces.