[Unity game development] Vector3 class

Common attributes:


normalized Normalized vector direction as a length of a
megnitude Vector length, vector mode is
forward  Vector3 (0, 0, 1) the extension of the z-axis positive direction
right Vector3 (1, 0, 0) x-axis positive direction extension
up Vector3 (0, 1, 0) extension of the y-axis positive direction

Common methods:


void Normalize ()  Standardization vector
static Vector3 Lerp (Vector3 from, Vector3 to, float t) Linear interpolation between the two vectors
static float Angle (Vector3 from, Vector3 to) The angle between the two vectors
static float Distance (Vector3 a, Vector3 b) The distance between the two vectors
   

SmoothDamp
public static Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime)
public static Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float maxSpeed)

Parameters ref Vector3 currentVelocity, this parameter can not be a local variable, must be a global variable is modified when the current speed, the value of every time you call this function; parameter smoothTime is to reach the target of about time, a smaller value will quickly reach target; maxSpeed parameter is selected to allow you maximum speed limit.

Guess you like

Origin blog.csdn.net/Alina_catty/article/details/79064143