MallNinjaMax

Some Vector Math

May 11th, 2021 (edited)
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.32 KB | None | 0 0
  1. public Vector3 vector;
  2. Vector3 axis = Vector3.up;
  3. float angle = 45.0f;
  4.  
  5. // Rotate a Vector3 by an angle on a given axis
  6. vector = Quaternion.AngleAxis(angle, axis) * vector;
  7.  
  8. // Flatten a Vector3 on the Y-axis
  9. float oldMagnitude = vector.magnitude;
  10. vector = new Vector3(vector.x, 0, vector.z).normalized * oldMagnitude;
Add Comment
Please, Sign In to add comment