Quaternion: Test the method properties in the quaternion (four-tuple) class through the API (i)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.