Skip to content

format

typescript
Vector2.magnitude

class: Vector2

description

(Read Only) Returns the length of this vector. This method is an accurate way to calculate the length of a vector, it returns the actual length of the vector. It is achieved by calculating the square sum of the vector (xx+yy), and then taking the square root.

parameter

param_nametypedescription

reture

typedescription
numberThe length of the vector.

code example

typescript
let rhs = new Vector2(3, 4);
Debug.Log(rhs.magnitude); // 5