Game Development Reference
In-Depth Information
c.
2 . If you only care about the direction of a vector, it is probably worthwhile
to normalize this vector. If you need both the direction and magnitude of
the vector, you should not normalize.
3 . || A - P || 2 <|| B - P || 2
4 . Project onto to get
, which extends all the way to the start
of .
The vector goes from to , so
.
Substitute for to get the final solution:
.
5 . Solution:
Normalize and .
Solve for θ using the dot product.
6 . This is × ≈ 0.23, - 0.12, - 0.47 .
You should normalize this, for a final value of 0.43, - 0.23, - 0.86 .
7 . This will return the normal that faces in the opposite direction.
8 . Take the player's forward vector and cross it with the vector from the
player to the sound effect. If the z value of the cross is positive, the sound
Search WWH ::




Custom Search