Unreal Engine Math Operators (Add, Subtract, Multiply, Equal…)

In Unreal Engine 5, as in many other programming environments, you can use various math operators to perform operations on numerical values.

These operators allow you to manipulate variables, perform calculations and make decisions within Blueprint scripts in Unreal Engine 5.

Unreal Engine Math Operators Blueprints

Math Operators in Blueprints

Here’s an explanation of the math operators in Unreal Engine 5 Blueprints:

  • Addition (+): The addition operator is used to add two or more numerical values together. For example, if you want to add the numbers 5 and 7, the result would be 5 + 7 = 12.
  • Subtraction (-): The subtraction operator is used to subtract one value from another. For example, if you want to subtract 3 from 10, the result would be 10 – 3 = 7.
  • Multiplication (*): The multiplication operator is used to multiply two or more numerical values. For example, if you want to multiply the numbers 4 and 6, the result would be 4 * 6 = 24.
  • Division (/): The division operator is used to divide one value by another. For example, if you want to divide 20 by 5, the result would be 20 / 5 = 4. Remember, dividing by zero is undefined and can lead to errors.

Comparison and Equal Nodes

In Unreal Engine, when you work with comparison and equal nodes, you’ll notice that their output pins are colored red. This indicates that they provide a Boolean result, which means they return either ‘true’ or ‘false’.

These nodes are typically used together with a ‘Branch‘ node to make decisions based on these true/false outcomes.

  • Greater Than (>): This operator checks if the left-hand side value is greater than the right-hand side value. For example, if you compare 8 > 3, the result is 8 > 3 which is true.
  • Less Than (<): This operator checks if the left-hand side value is less than the right-hand side value. For example, if you compare 4 < 9, the result is 4 < 9 which is true.
  • Greater Than or Equal To (>=): This operator checks if the left-hand side value is greater than or equal to the right-hand side value. For example, if you compare 5 >= 5, the result is 5 >= 5 which is true.
  • Less Than or Equal To (<=): This operator checks if the left-hand side value is less than or equal to the right-hand side value. For example, if you compare 6 <= 6, the result is 6 <= 6 which is true.
  • Equal (==): This operator checks if the left-hand side value is equal to the right-hand side value. For example, if you compare 10 == 10, the result is 10 == 10 which is true.
  • Not Equal (!=): This operator checks if the left-hand side value is not equal to the right-hand side value. For example, if you compare 7 != 3, the result is 7 != 3 which is true.

Here’s an example of an equal operator that generates a Boolean result. If the number is equal to one, it will return true; otherwise, it will return false.

If you don’t understand the example, read these three lessons first: Print String, Keyboard Events and Variables. The Random Integer node just generates a number between 0 and 1, but since it begins counting from 0, we input a value of 2 for it to output two integers, 0 and 1. To avoid bugs, we save this number in a variable.

UE5 Boolean Example

Pin Conversions

There are two ways to convert an Operator to a Data Type. The type will usually be an Integer, Vector, Float or Byte.

The first way is to connect a variable directly to the math operator. If you connect an integer value, the math operation will automatically work with integers.

The second option is to right-click on one of the three pins and choose the data type you want.

Don’t forget, if you click the ‘Add pin +’ button, you can add more input pins as needed.

Unreal Engine Math Pin Conversion

Math Operators in Unreal Engine: Practical Examples

If you’re just starting out with Unreal Engine, a great way to learn is by experimenting with Math Operator nodes, variables, and Print String.

Try creating simple calculations and see how they affect your game. Use Print String to display the results.

This hands-on approach will help you understand how everything works together.

Have fun and keep exploring!

UE Math Blueprint Example

Unreal Engine Learning Path