1. Transform. Rotation: rotation of the object in the world coordinate system; transform. localrotation: rotation of the object in the Local Coordinate System of the parent object. The two variables are of four types.
(1) Get the angle-axis representation of the current rotation of the game object
Transform. Rotation. toangleaxis (angle, axis );
(2) return to zero. The coordinate axes of the local coordinate system are parallel to those of the world coordinate system.
Transform. Rotation = Quaternion. identity;
(3) orientation the object to the target
Relativepos = target. Position-transform. position;
Rotation = Quaternion. lookrotation (relativepos );
Transform. Rotation = rotation;
(4) moving an object from a smooth difference to can be used to simulate the effect of the camera's transition from object A to object B.
Transform. Rotation = Quaternion. slerp (from. rotation, To. rotation, time. deltatime * speed)
2. Coordinate System: common coordinate systems include the world coordinate system, local coordinate system, camera coordinate system, and screen coordinate system. Transform. transformpoint can be used to convert coordinate points from a local coordinate system to a world coordinate system, transform. inversetransformpoint can convert coordinate points from the world coordinate system to the local coordinate system; transform. transformdirection and transform. inversetransformdirection converts vectors between the world coordinate system and the local coordinate system. For example, convert the object location to the coordinates in the camera coordinate system:
Cam = camera. Main. Transform;
Camerarelative = cam. inversetransformpoint (transform. position)
If (camerarelative. z> 0)
Debug. Log ("the object is in front of camera ");