Sign in to follow this  
funnymango

Why to normalize Vector2.one in Unity?

Recommended Posts

Due to the documentation, Vector2.one is the vector (1,1) which has the length sqrt(1^2 + 1^2) = 1.4142 approx., so it is not of unit length.

 

EDIT. For the case you do not know: The normalization ensures that the length of the vector is 1, not that all of its components are 1. So, in this case, the result of normalization would be approximately

    (1,1) / length( (1,1) ) = (1,1) / 1.41412 = (0,707,0.707)

 

This step ensures that the velocity vector has a length equal to the value of speed. Otherwise its length would depend on the actual direction, so you would have higher speed in diagonal directions than in principal directions.

Edited by haegarr

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this