"someValue = anotherValue > 0.1" What does this mean?

I have been trying to understand the PlatformerController script from the 2D platformer tutorial and ran into this line: movement.isMoving = Mathf.Abs (h) > 0.1;

What exactly does this mean? I can't find any specific information on this kind of syntax.

It's quite simple:

`=` is the assignment operator.

movement.isMoving = Something sets the value of movement.isMoving to the value of Something. movement.isMoving is a bool value, meaning that it is either true or false and as such Something must be a boolean value.

`>` is the greater than operator.

Mathf.Abs(h) > 0.1 compares the values of Mathf.Abs(h) and 0.1 and returns the boolean value of whether Mathf.Abs(h) is larger than 0.1.

As a result, movement.isMoving is set to the boolean value indicating whether Mathf.Abs(h) is greater than 0.1.

Short version:

someValue = anotherValue > 0.1 What does this mean?

It means that someValue become true if anotherValue is greater than 0.1, otherwise false.

``````if (anotherValue > 0.1)
{
someValue = true;
}
else
{
someValue = false;
}

``````

Long version:

Mathf.Abs is a function that returns the ABSolute value of the argument passed in.

The absolute value is a number value where you simply remove the negative sign.

Examples:

• Mathf.Abs ( -3 ) return 3.
• Mathf.Abs ( 3 ) also return 3.

The expression is formed such as "boolean = a > b". a is Mathf.Abs( h ) and b is 0.1. If a is greater than b, then the expression evaluate to true. Otherwise false.

The sign > is a relational operator and is very common in programming.

In short:

• movement.isMoving = true if h is greater than 0.1 or smaller than -0.1.
• movement.isMoving = false if h is between 0.1 and -0.1.

What h is, I have no clue. Probably height from ground. It's a bad name for a variable and I haven't seen the tutorial.

"Mathf.Abs (h) > 0.1" is a condition that returns either true or false. Mathf.abs returns the absolute value of the input (meaning if the input is -5 it returns 5). If Mathf.Abs (h) is larger than 0.1 the condition is true, otherwise it is false.

The "movement.isMoving =" part in front of it just sets the isMoving property to the returned value of the condition.