Change GameObject pivot point

前端 未结 1 2004
一个人的身影
一个人的身影 2021-01-22 14:15

Unity object not rotating in center. It was fine until an hour, I don\'t believe I changed the code or anything. I have also tried messing with the pivot/centre buttons on the t

相关标签:
1条回答
  • 2021-01-22 14:40

    The default space of the Rotate function Space.Self. You should provide Space.World to its third parameter to make it rotate in world space.

    transform.Rotate(0f, 0f, speed * Time.deltaTime, Space.World);
    

    If this does not solve your problem, you have to open your model up in any 3D application such as Maya and reset/center the pivot point then re-import it into Unity.

    You can also use another GameObject as parent of this GameObject you want to rotate to solve this pivot issues.

    1.Create a new GameObject

    2.Move it to the center position of the object you are rotating.

    3.Once you are fine with that location, drag that object you are rotating under the GameObject created in #1. The GameObject you are rotating should now be a child of that GameObject created in #1.

    You can now rotate the GameObject created in #1 instead.

    Although, I hate doing that but it works too. I suggest using a 3D application to do it to move the pivot point.

    0 讨论(0)
提交回复
热议问题