Calculating the length of a vector in Unreal Engine

- by

I had to calculate the length of a vector recently, and had no idea where to begin. In my little farm/planting project, I’ve used Line Tracing to plant a vegetable on the floor. However, I needed a limitation as to where the player can plant things. They should not be allowed to plant directly underneath the player character, nor should they be able to plant as far as the line cast goes.

The easiest way to calculate this was using the Vector Length node. Here’s how I’ve managed to do it:

This function takes a Vector as input, then subtracts the player character’s location from it and determines the vector length. If it’s within the radius I’m comfortable with, it’s output boolean will be set.

Add your voice