Exemple #1
0
 public static Vector3 Projection(Vector3 target, Vector3 direction)
 {
     return Dot(target.Normalized(), direction) * target.Normalized();
 }
Exemple #2
0
 /// <summary>
 /// Returns a vector that is closer to target from current by an amount
 /// defined by step. If step is greater than distance, target is returned.
 /// </summary>
 /// <param name="current"></param>
 /// <param name="target"></param>
 /// <param name="step"></param>
 /// <returns></returns>
 public static Vector3 MoveStep(Vector3 current, Vector3 target, float step)
 {
     Vector3 tempVector = new Vector3(target - current);
     if (tempVector.magnitude > step)
         return (current + (tempVector.Normalized() * step)); // The distance is more than step, so return a point that is step amount closer to target than currenty
     else return target; // Return target to not overshoot (i.e. go past) the target when step was greater than the remaining distance
 }