I want to rotate an object through C#, however I don’t want to use the world axis. Instead, I want to rotate it through the axis that appear when you select the object with the rotation tool, as shown bellow:
Is there a way to do this through C#?
I want to rotate an object through C#, however I don’t want to use the world axis. Instead, I want to rotate it through the axis that appear when you select the object with the rotation tool, as shown bellow:
Is there a way to do this through C#?
You mean the object’s local axes?
Take a look at the Quaternion class and its many helper functions. Among them are Quaternion.AngleAxis, where you can pass in any axis around which you want to rotate - you can pass in things like transform.up, transform.right, and transform.forward, for example.
You can also use the * operator on two quaternions to combine them. So for example,
transform.rotation = transform.rotation * Quaternion.AngleAxis(30f, transform.up);
Would rotate an object 30 degrees to its own right (e.g. around the up axis).
That’s exactly what I need thanks for the help.