1,transform rotating transform. Rotate (X, Y, Z);//rotation around the x, Y, Z axis, can be written around an axis rotation, chestnut transform. Rotate (0, 90, 0); Transform. Rotate (Vector3.right * time.deltatime),//with Euler angle rotation, the order is zxy,right is rotated 1 degrees to the X axis transform. Rotate (0, 0, Space.world);//rotation of the XYZ axis around the world coordinate system, that is, the coordinate system of its top parent, if it is not different at the top, it does not revolve around a point, but instead rotates transform in its own coordinate system. Rotate (Vector3.up, space.self);//rotates around its own coordinate system, which is the default transform. Rotatearound (Vector3.zero, Vector3.up, time.deltatime);//rotate around point, rotate axis, angle transform.rotation = quaternion.identity;// Rotation can be specified directly by the number of four transform.eulerangles = new Vector3 (angle);//By the Euler angle directly specify auto-rotation: Rotate in update and match Time.deltatime to 2.Quaternion $ four
- Angleaxis (angle:float, Axis:vector3) rotates angle around the axis axis, creating a rotation.
- Angle (a : quaternion,b : quaternion) returns the angle between A and B.
- Dot dot multiply usage ibid.
- Eulerangles returns the Euler angle that represents the rotation.
- Euler (x : float,y : float, z : float) is used to return a specified Euler angle, which is useful when using Euler angles to represent rotations
- Fromtorotation (fromdirection : Vector3,todirection : Vector3) to create a rotation from the from-to-to (four-dollar rotation calculation)
- The identity is equivalent to "no rotation": This object is completely aligned to the world or to the parent axis.
- Inverse returns the reverse rotation.
- Lerp interpolation
- Lookrotation Gaze rotation
- Operator! = operator is not equal to
- operator * operator multiplication
- the operator = = operator equals
- quaternion construction of four yuan
- Rotatetowards Steering
- Setfromtorotation rotation from the From
- Setlookrotation Gaze rotation
- Slerp spherical interpolation
- This [int index] Action index
- Toangleaxis converts a rotation with a "angle-axis" representation.
- ToString to String
- W Components
- X component
- Y component
- Z Component
From the above we can see that we can either rotate by the angle-axis or calculate the rotation angle smoothly according to the vector: Transform.rotation = Quaternion.slerp (from:quaternion, To:quaternion, time.fixedtime* smooth); Lerp interpolation is faster than Slerp, but if the rotation is more distant, it looks worse. Gaze rotation: quaternion lookrotation (Vector3 forward, Vector3 upwards), creating a rotation along the forward (z-axis) and the head along the upwards (y-axis) of the constraint gaze. That is, create a rotation so that the z axis is facing up toward the forward,y axis. The resulting result is a rotation angle that is oriented toward the forward, which is useful for controlling the rotation of the character 3, the rigid body rotates the rigidbody. Moverotation (rot:quaternion) for kinematic rigid bodies, it applies friction based on the motion of the rigid body. Simulates the rotation of a rigid body. If you want the other rigid body to interact with the kinematic rigid body, you need to use it in the Fixedupdate function.
4, gaze at transform. LookAt (target:transform, Worldup:vector3 = vector3.up) Rotates the object so that the z-axis (forward) points to the target object. When the object is set LookAt and the target object is specified, the object's z-axis will always point to the target object, and when the worldup axis is set, the object is rotated more closely to the specified axis, noting that Worldup refers to the world space, regardless of the position of your object, The rotation becomes more flexible as long as it is close to the specified axis direction. 5,dotween rotation
Transform. Dolocalrotate (); transform. Dorotate ();//function is not clear, it should be on these two, not clear can be found in Unity rotation rotation default is stored in four yuan, according to our custom is Euler angle, usually need to convert Euler angle to four yuan number
Unity Script-rotate Rotation-related knowledge points