Search code examples
rotationunity-game-enginetransformflipquaternions

How to Flip a Gameobject around Y axis Unity


I am trying this to flip a gameobject around Y axis in Unity

newCellModel2.transform.rotation=Quaternion.AngleAxis(180, Vector3.up);

Can anybody tell me if that is wrong or right because I am not getting a desired result Note that my Newmodel is of |_ shape so when i flip it by y axis it should be like this _|

Any help would be appreciated


Solution

  • You're setting the rotation. This means that if you've already flipped Newmodel, it's not going to have any effect (which I'm guessing is what you're seeing instead of desired behavior). Assuming your ascii art has x axis right and y axis toward the top of the page, you might be looking for:

    transform.RotateAround(Vector3.up, Mathf.PI);