- Home /
How to rotate object around specified axis using AddTourque() instead of transform.RotateAround()
Dear Peoples
I have a gameobject (flying airplane) that i want to rotate around a specified axis. The airplane is supposed to yaw up and down.
This would be very easy with rb.AddRelativeTourque(0,0,torque). However, when the plane is currently tilted towards left/right (tilt around its forward axis) the function wouldnt yaw the plane straightly up/down anymore, but instead also slightly in direction of the tilt.
so my desired rotation axis is (transform.right.x,0,transform.right.z). i can rotate my plane around this axis using transform.RotateAround() with its own position as the rotation center point:
Vector3 rotationAxis = new Vector3(transform.right.x,0,transform.right.z); transform.RotateAround(transform.position, rotationAxis, 30.0f*Time.deltaTime);
This works almoust just the way i want it to, however, Id rather do this with AddTourque()/AddRelativeTorque() to respect collision and inertia. But im to stupid to think about how this would be done, so I need your help!
Kind regards and thanks in advance.
Answer by xxmariofer · Oct 27, 2020 at 06:19 PM
you cant use add torque to achieve that behaviour, you are looking to "orbit" an object, take a look into this forum https://forum.unity.com/threads/orbital-physics-maintaining-a-circular-orbit.403077/
Your answer
![](https://koobas.hobune.stream/wayback/20220613014631im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Figuring out the correct amount of torque to apply? 2 Answers
Torque stopped working after update 1 Answer
how to rotate a Rigidbody to a target rotation using Rigidbody.AddTorque() 0 Answers
How to move a rigidbody along a curve or spiral 0 Answers
Addtorque towards a point, compensate for its inertia? 0 Answers