QUICK DEV TIP #62 UE4 / UE5 - MATHS IN VARIABLES

Here’s a little tip that will help you out from time to time!

Did you know you can perform maths in float and int variables in the Unreal Engine editor?

If you would prefer to watch the video version, check it out here

In the gif below you can see that I am playing around with the default value of a float variable. I am able to perform additions, subtractions, multiplications, and divisions to the number.

 

This is exactly the same for int variable types as well

 

Because the linear colour struct variable type is made up of four floats it also works here. Other structs it would work on are Locations (vectors), Rotations (rotators).

 

It is also not only inside blueprints we can do this, its also possible in float values in other places such as the material editor.

 

This seems to work exactly the same way in the Early Access version of Unreal Engine 5. In the example below you can see another use for it. I want my asset to be twice as high as it currently is, so I can go to the Z of the location vector in the details panel and multiply it by 2 (e.g. X*2). I then do the same for the Z rotation.

This is a great little tip for helping speed things up a little bit. With smaller numbers maths is easy to do in your head but this tip can come in particularly handy when you are working with larger numbers. I have also used it when for example when I know the height of my player and I want to remove it from a world location, I can simply minus the value in the variable itself e.g. X-playerHeight instead of needing to do the maths myself.

If you want more quick tips & tricks FOLLOW ME ON TWITTER @cbGameDev

Also, check out the parkour game I'm solo developing called Freerunners. Give it a wishlist if you like the way it looks!: https://store.steampowered.com/app/1430330/Freerunners/