When it comes to inertia rotation, I think of wheel Collider, which simulates the rotation of cars, including wheels. What I want is the first speed of an object, when an object is blocked by a variety of forces, the rotation speed of our object will get smaller and smaller, and finally it will be static.
If you want to add the rigidbody to an object, I will use the method of the rigidbody AddTorque function. Do not use AddRelativeTorque because it is local. You will know it if you try it; these two functions are used in FixedUpdate. First, let's take a look at the effect of the AddTorque function. You will find that the direction of the torque is determined by the right hand and the orientation of the object is vertical. The thumb indicates the direction of the torque, and the four fingers indicate the direction of the rotation. On the mobile phone, two directions are rotated, respectively, around the Y axis and the X axis, so the Z axis is 0, regardless of him. Similarly, we still use Input. getAxis ("Mouse X/Y") function, you will use their size to indicate the direction of the rotation, also according to the right hand determine the direction of the torque, then, add some resistance to the Drag and Angular Drag of the Rigidbody. Do not add too much. It cannot be rotated.
[Java]
Var h: float;
Var v: float;
Var Torque: Vector3;
Function FixedUpdate (){
Rigidbody. AddTorque (Torque * 1 );
}
Function Update (){
If (Input. GetTouch (0). phase = TouchPhase. Moved ){
H = Input. GetAxis ("Mouse X"); // positive and left negative
V = Input. GetAxis ("Mouse Y"); // top, bottom, and bottom
}
Else {
H = 0;
V = 0;
}
Torque = Vector3 (v,-h, 0 );
If (Input. GetKey (KeyCode. Escape )){
Application. Quit ();
}
}
From dlnuchunge's column