1. Difference Method Lerp
Returns a four-dollar number that returns the difference between from and to and varies with time.detaltime*speed
Quaternion.lerp (From.rotation,to.rotation,time.detaltime*speed);
For example, in the following code c,d will start with A.rotation as the starting point, with the b.rotation as the end point at total for the speed of the change
usingUnityengine;usingSYSTEM.COLLECTIONS;PUBILCclasseaxmble:monobehaviour{ PublicTransform a,b,c,d;floatSpeed=0.2f;floatTotal=0.0f;voidstart () {}voidUpdate () { total+=time.deltatime*Speed ;if(total>=1.0f) Total=1.0f; C.rotation=quaternion.lerp (a.rotation,b.rotation,total);D. Rotation=Quaternion.lerp (a.rotation,b.rotation,total); }}
Lerp
2.LookRotation method
A:quaternion.lookrotation (Vector3.forword);
B:quaternion.lookrotation (vector3.forword,vector.up);
Personal opinion: Not very understanding of this method, but know some of its usage,
Vector3.forword should be transform.position-target.position so that you can achieve the z axis of gameobject always pointing to target.posotion
A method is to follow Vector3.up as the axis of rotation
The rotation axis of the B method can be achieved by defining the vector.up to revolve around its own transform.up or around Vector.up, or other
Here is the code for the test
Lookposition
Quaternion: Test the method properties in the quaternion (four-tuple) class through the API (i)