SHARE
TWEET

Untitled

a guest Jan 18th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System;
  3.  
  4. public static class P5
  5. {
  6.     public static Vector2 Limit(Vector2 v, float limit)
  7.     {
  8.         return v.sqrMagnitude < limit * limit ? v : v.normalized * Mathf.Abs(limit);
  9.     }
  10.  
  11.     public static Vector3 Limit(Vector3 v, float limit)
  12.     {
  13.         return v.sqrMagnitude < limit * limit ? v : v.normalized * Mathf.Abs(limit);
  14.     }
  15.  
  16.     public static Vector2 SetMag(Vector2 a, float magnitude)
  17.     {
  18.         a.Normalize();
  19.         return a * Mathf.Abs(magnitude);
  20.     }
  21.  
  22.     public static Vector3 SetMag(Vector3 a, float magnitude)
  23.     {
  24.         a.Normalize();
  25.         return a * Mathf.Abs(magnitude);
  26.     }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top