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

A physics bug in 2019.1 when using Rigidbody.MovePosition() and Continuous Speculative

Discussion in 'Physics' started by wlad_s, Sep 1, 2019.

  1. wlad_s

    wlad_s

    Joined:
    Feb 18, 2011
    Posts:
    148
    I have discovered a bug in physics that I'm sure it wasn't there in 2018.2.15 because my game worked fine until I updated to 2019.1.12

    This is the setup:
    There is a bullet sphere of 0.5m scale with a sphere collider and a kinematic rigidbody. It is moved in FixedUpdate by calling Rigidbody.MovePosition(newPos); RB is set to interpolate and Collision Detection Mode is set to Continuous Speculative (which is the only continuous option for kinematic RBs)

    There are also some cubes 1m wide, with Box Colliders and a non-kinematic RB but their positions are frozen.

    What should happen: A bullet should only hit one cube because it's smaller than its width.
    physicsBug2.png

    What happens: The bullet hits the central cube and two or even more adjacent cubes which are well far away from the bullet's actual collider.
    physicsBug.png

    Interestingly, when the bullet is moved by transform.position = newPos, instead of Rigidbody.MovePosition(newPos), it makes a collision as it should, but then the visible position isn't interpolated (which can be clearly seen if you decrease the Timescale to 0.1 or 0.2).

    The way the position is updated can be changed by toggling useRbMovePosition on the bullet object in the inspector.


    Here's the project: https://we.tl/t-1gHHonb15B

    Is this really a bug or is my setup flawed? Should I file a bug report?

    Cheers
     
    Last edited: Sep 1, 2019
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,495
    Yes, I'd recommend you to file a bug report with that minimal repro scene. I'd also check if it behaves correctly in the latest 2018.4 version. It would be good to specify whether it's a 2019-only bug, or it was introduced in some 2018 release.

    EDIT: BTW, have you checked in the different collision detection modes make some difference?
     
  3. wlad_s

    wlad_s

    Joined:
    Feb 18, 2011
    Posts:
    148
    Last edited: Sep 3, 2019
    Edy likes this.