functions Methods 18

Abs ()
Vector2
Returns a new vector with all values positive. -5 becomes 5, etc.
AddClamped (toAdd, maxLength)
Vector2
Try to add to this vector. If we're already over max then don't add. If we're over max when we add, clamp in that direction so we're not.
AlmostEqual (v, delta)
bool
Returns true if we're nearly equal to the passed vector.
Angle (other)
float
Returns the distance between this vector and another in degrees.
Approach (length, amount)
Vector2
Returns a new vector whos length is closer to given target length by given amount.
Clamp (otherMin, otherMax)
Vector2
Returns a vector each axis of which is clamped to between the 2 given vectors. Basically clamps a point to a square.
ClampLength (maxLength)
Vector2
Returns a vector whose length is limited to given maximum
ComponentMax (other)
Vector2
Returns a vector that has the maximum values on each axis between this vector and given vector.
ComponentMin (other)
Vector2
Returns a vector that has the minimum values on each axis between this vector and given vector.
IsNearlyZero (tolerance)
bool
Returns true if value on every axis is less than tolerance away from zero
LerpTo (target, t, clamp)
Vector2
Linearly interpolate from this vector to given vector.
RotateAround (center, angleDegrees)
Vector2
Rotate this vector around given point by given angle in degrees and return the result as a new vector.
SnapToGrid (gridSize, sx, sy)
Vector2
Snap to grid along all 3 axes.
SubtractDirection (direction, strength)
Vector2
Given a vector like 1,1,1 and direction 1,0,0, will return 0,1,1. This is useful for velocity collision type events, where you want to cancel out velocity based on a normal. For this to work properly, direction should be a normal, but you can scale how much you want to subtract by scaling the direction. Ie, passing in a direction with a length of 0.5 will remove half the direction.
WithAcceleration (target, accelerate)
Vector2
Move to the target vector, by amount acceleration
WithFriction (frictionAmount, stopSpeed)
Vector2
WithX (x)
Vector2
Return this vector with given X.
WithY (y)
Vector2
Return this vector with given Y.

functions Static Methods 19

CubicBezier (source, target, sourceTangent, targetTangent, t)
Vector2
Calculates position of a point on a cubic bezier curve at given fraction.
Direction (from, to)
Vector2
Calculates the normalized direction vector from one point to another in 2D space.
Distance (a, b)
float
Returns distance between the 2 given vectors.
DistanceBetween (a, b)
float
Returns distance between the 2 given vectors.
DistanceBetweenSquared (a, b)
float
Returns squared distance between the 2 given vectors. This is faster than DistanceBetween, and can be used for things like comparing distances, as long as only squared values are used.
DistanceSquared (a, b)
float
Returns squared distance between the 2 given vectors. This is faster than DistanceBetween, and can be used for things like comparing distances, as long as only squared values are used.
Dot (a, b)
float
Returns the scalar/dot product between the 2 given vectors.
FromDegrees (degrees)
Vector2
Returns a point on a circle at given rotation from X axis, counter clockwise.
FromRadians (radians)
Vector2
Returns a point on a circle at given rotation from X axis, counter clockwise.
GetAngle (v1, v2)
float
Returns the distance between two direction vectors in degrees.
Lerp (a, b, frac, clamp)
Vector2
Linearly interpolate from point a to point b.
Max (a, b)
Vector2
Returns a vector that has the maximum values on each axis between the 2 given vectors.
Min (a, b)
Vector2
Returns a vector that has the minimum values on each axis between the 2 given vectors.
Parse (str)
Vector2
Given a string, try to convert this into a Vector2. Example formatting is "x,y", "[x,y]", "x y", etc.
Reflect (direction, normal)
Vector2
Returns a reflected vector based on incoming direction and plane normal. Like a ray reflecting off of a mirror.
SmoothDamp (current, target, velocity, smoothTime, deltaTime)
Vector2
Smoothly move towards the target vector
Sort (min, max)
Sort these two vectors into min and max. This doesn't just swap the vectors, it sorts each component. So that min will come out containing the minimum x and y values.
SpringDamp (current, target, velocity, deltaTime, frequency, damping)
Vector2
Springly move towards the target vector
TryParse (str, result)
bool
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.