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, and then give the Rigidbody drag and angular drag, add some resistance, don't add too much. Too much will not rotate.
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, left, negative, V = input. getaxis ("Mouse y"); // upper positive and lower negative} else {H = 0; V = 0;} torque = vector3 (v,-h, 0 ); if (input. getkey (keycode. escape) {application. quit ();}}