Whats wrong with AddTorque and compound colliders ?
I make Rigidbody with compouded box colliders as childs and constraint everything except Y rotation
Have a c# script which apply AddTorque to rigidbody
public class Rotator : MonoBehaviour {
Rigidbody rb;
void Start () {
rb = GetComponent<Rigidbody> ();
}
void OnMouseDown (){
rb.AddTorque (0,20f,0);
}
}
I apply addTorque and expect rigidbody will rotate around world-Y-axis. But in some cases rotation is magicaly affected (See fig.)
Reproduced in 5.0, 5.3, 5.4, 5.5 Unity
Normaly worked in 4.6
Is it bug?
you're running the code on the Update-Loop.
try saving the mouse down to a bool and read it in fixed update and apply the torque there.
Answer by SnegCozine · Dec 28, 2016 at 02:47 PM
Ok. Solution found. Need to reset inertiaTensorRotation like this https://docs.unity3d.com/ScriptReference/Rigidbody-inertiaTensorRotation.html and all perfectly work
Your answer
![](https://koobas.hobune.stream/wayback/20220612102325im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Collider For Triangular Object 1 Answer
Best possible way to implement physics on a chariot 2 Answers
Help achieving a pogo stick like shock absorbing leg 0 Answers
Collider fires consistently, but Trigger does not? 0 Answers
How to not draw a surface if a certain other surface is behind it 0 Answers