Mathf Functions

The following Unity Mathf functions can be used in parameter and relation expressions, scene and runtime handles, and Turtle Scripts.

Mathf
Abs(var)
abs(a)
convert float to absolute (positive)
Acos(var)
acos(f)
returns the arc-cosine of f,
the angle in radians whose cosine is f.
Asin(var)
asin(f)
Returns the arc-sine of f,
the angle in radians whose sine is f.
Atan(var)
atan(f)
Returns the arc-tangent of f,
the angle in radians whose tangent is f.
Atan2(a,b)
atan2(a,b)
arctan(a,b)
Returns the angle in radians whose Tan is y/x.
Ceil(a,b)
ceil(a,b)
CeilToInt(var)
ceilToInt(f)
Returns the smallest integer greater to or equal to f.
Clamp01(var)
clamp01(f)
Clamps value between 0 and 1 and returns value.
Cos(var)
cos(f)
Returns the cosine of angle f.
Epsilon
epsilon
constant (read-only): the smallest enum
Exp(var)
exp(
f)
Returns e raised to the power of f.
e is ~2.718282
Floor(var)
floor(f)
FloorToInt(var)
floorToInt(f)
Returns the largest integer smaller than or equal to f.
Greater(a,b)
greater(a,b)
picks the greater of 2 values,
can be equal
int(f)same as floor()
IsEven(var)
isEven(a)
iseven(a)
bool returns true when value is even
Lerp(a,b,time)
lerp(a,b,t)
Linearly interpolates between a and b by t.
Lesser(a,b)
lesser(a,b)
picks the lesser of 2 values,
can be equal
Max(var,a)
max(
a,b)
Returns largest of two values.
Min(var,a)
min(
a,b)
Returns the smallest of two values.
Modulo(a,n)
modulo(a,n)
remainder of int a divided by float n, where n is not zero (NaN)
MoveTowards(var,a,b)
moveTowards(
a,b,c)
Moves a value current towards target.
MoveTowardsAngle(var,a,b)
moveTowardsAngle(
a,b,c)
Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
PI
pi
constant (read-only): ~3.141593
Pow(f,p)
pow(
a,b)
Returns f raised to power p.
Range(var,a,b)
range(var,a,b)
clamps a value between 2 floats/ints.
b must be greater than a
Repeat(time,length)
repeat(
a,b)
Loops the value t, so that it is never larger than length and never smaller than 0.
rnd(f)
rnd(a,b)
random float
random range
Round(var)
round(
f)
Returns f rounded to the nearest integer.
Sign(var)
sign(
f)
Returns the sign of f.
(-1 or 1)
Sin(var)
sin(f)
Returns the sine of angle f.
Sqrt(var)
sqrt(f)
Returns square root of f.
Tan(var)
tan(f)
Returns the tangent of angle f in radians.

Comments are closed.