0
\$\begingroup\$

I was watching a tutorial about Vectors in Unity, I understood the meaning of normalizing a vector but I wanna know why do we normalize a vector and if we don't what will happen ?

\$\endgroup\$
  • 3
    \$\begingroup\$ I voted to close this question as "unclear what you are asking". There are lots and lots of different situations in Unity where you are working with vectors, and there are different reasons why you would normalize them. Please explain where these vectors come from and what they are used for. Then we can try to explain why you need to normalize them in this particular situation. \$\endgroup\$ – Philipp Aug 21 '18 at 12:02
  • 1
    \$\begingroup\$ Move spaceship from A to B. Get Direction by B - A. Set spaceship velocity to Direction. Their speed is now faster if they have to travel farther. By normalizing it first, there is a constant speed regardless of how far they have to travel. \$\endgroup\$ – Evorlor Aug 21 '18 at 21:46
  • \$\begingroup\$ @Philipp I wanted to move a character from one point to another with some speed. \$\endgroup\$ – Abhinay Singh Negi Aug 23 '18 at 10:12
1
\$\begingroup\$

There are reasons someone might want to normalise a Vector, including dealing with directions. Normals on meshes, for example, are normalised, because you only care about their direction, not their length.

It also makes the math work, because if you have multiple normal vectors with different lengths, it would be impossible to calculate values (like lighting) in a uniform way.

\$\endgroup\$
1
\$\begingroup\$

There are operations that do not make sense when the vector is not normalized. Some examples:

  1. When you want to get the projection of a vector on another vector. You want to normalize the second one so that you only get its direction.
  2. When you are dealing with basis vectors in a Cartesian coordinate system. This is where matrix transformations and viewing in 3D space comes into play.

There are a lot more, but this is the gist of it.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.