- Home /
apply Angular Velocity around an arbitrary axis?
How can I make a cube rotate around any axis with physics. For example take a cube and rotate it 45 degrees around the Z axis. If there was an arrow at the top of the cube that was pointing north it would now be pointing northeast. How do I get it to spin around the northeast axis with physics?
Answer by Bunny83 · Dec 16, 2017 at 02:14 AM
Uhm your description sounds a bit confusing. However the angularVelocity of a Rigidbody is the rotation axis defined in world space. It's length defines the rotation speed.
So you can simply set the angularVelocity of your rigidbody to your desired axis. For example
rb.angularVelocity = rb.transform.up * speed;
where "rb" is a reference to your Rigidbody component and speed is just a float value. This will make the object rotate around it's "local" up vector. "Transform.up" returns the objects up vector in worldspace.