0
votes

I have a prefab layer object (rectangle) which is rotated bei some degrees to have the right angle to be seen by my 2d camera.

Now i want to rotate the object by x degrees around the Vector3.up axis.

this.gameObject.transform.RotateAroundLocal(this.gameObject.transform.up,angle);

I also tried Vector3.up as the axis and RotateAround , none of that produces the expected result. It rotates some, but not the correct angle somehow.

1

1 Answers

1
votes

When it comes to 2D, I usually use orthographic camera looking at XY plane with Z axis pointing away from it. In which case I rotate things as follows:

gameObject.transform.Rotate(0, 0, angle, Space.World);

Which is angle degrees around Z axis clockwise.

In your case, I guess, it would be

gameObject.transform.Rotate(0, angle, 0 Space.World);