Skip to content

Api > Vector2 > ClampMagnitude()


Vector2.ClampMagnitude(Vector2 vector, number maxLength)⚓︎

Returns a copy of vector with its magnitude clamped to maxLength.

Parameters:⚓︎

Name Type Description
vector Vector2 vector
maxLength number maxLength

Returns:⚓︎

type Description
Vector2 a copy of vector with its magnitude clamped to maxLength.

Usage⚓︎

---@type Vector2
local vector;

---@type number
local maxLength;


local val0 = Vector2:ClampMagnitude(vector, maxLength)