Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


MoveTowards(Vector4, Vector4, float)

Moves a point current towards target.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public static Vector4 MoveTowards(Vector4 current, Vector4 target, float maxDistanceDelta)

Parameters

current

The current point.

target

The target point.

maxDistanceDelta

The maximum distance to allow. Use a negative value to push the vector away from the
target
.

Returns

Type

Description

Vector4The new position, moved from
current
towards
target
by at most
maxDistanceDelta
.

Remarks

This is essentially the same as Vector4.Lerp but instead the method ensures that the distance moved never exceeds
maxDistanceDelta
. Negative values of
maxDistanceDelta
pushes the vector away from
target
.