Search Issue Tracker

Won't Fix



Found in







Issue ID




[Physics2D] Rotating flipped Rigidbody2D leads to constant rotation



Steps to reproduce:
1. Download and open the user's project ""
2. Enter Play mode with SampleScene active
3. Use the UI buttons to control the direction of the Rigidbody2D
4. Flip the Rigidbody2D so that it's Y-axis is -180°
5. Click the rotate button

Expected Result: The Rigidbody2D rotates 90° in the Z-axis and continues moving forward
Actual Result: The Rigidbody2D continuously rotates by 90° every fame

Reproducible with: 2018.4.32f1, 2019.4.21f1, 2020.2.6f1, 2021.1.0b10, 2021.2.0a7

- Added a repro project "Repro" for 2018.4 since downgrading the user's project results in a lot of errors
- Possible workaround is to use the Transform.Rotate() function

  1. Resolution Note:

    If you take a look at the Rigidbody2D component in the inspector and open the "Info" foldout you'll see that the body isn't rotating at all. What is happening is that the Quaternion for rotation is providing different solutions to the same rotation causing issues (flipped Quaternion). This isn't dealt with in the physics system.

    Inherently this is a 2D system so rotating in 3D space makes it difficult for a system that only has a single degree of rotational freedom (Z).

    It is highly recommended that you use Transform.localScale to flip the direction and NOT rotate in 3D space as you can encounter these Quaternion ambiguities.

    Here's the change:

    public void Flip()
    #if false
    transform.rotation = Quaternion.LookRotation(-transform.forward, transform.up);
    transform.localScale = Vector3.Scale(transform.localScale, new Vector3(-1f, 1f, 1f));

    With the above change, the Transform quaternion doesn't alternate and cause issues. This issue is one fo the few times this has come up so making major changes in an attempt to deal with this isn't a risk we can take right now.

Comments (1)

  1. sztobar

    Mar 25, 2021 21:22

    I see. That explains why I saw transform.localScale modifications in officual unity guides instead of transform.rotation. Thanks for clarification.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.