Home > Blockchain >  Rotate a body about a given point Unity2d
Rotate a body about a given point Unity2d

Time:08-24

How to rotate a body relative to given dx dy in Unity? For example, I have a weapon sprite with a hand, and I was able to make it rotate relative to its center so that the weapon looks at the cursor, how can I rotate not relative to the center of the sprite, but relative to a given point?

CodePudding user response:

The simplest way to achieve this is to set a gameobject at your desired point and make your object child of the created object. So when you rotate the parent, it will rotate relative to the parent point.

CodePudding user response:

You can create an empty object and set the body as its child, then rotate the parent, the body will rotate around the parent like the parent be its pivot. This is a practical way to set the pivot, and you can change it at any time.

  • Related