Advertisement
mew_fi

Can I jump?

Jan 16th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1. // Invoking Unground sets grounded to false
  2. // CancelInvoke stops it from happening
  3. // First I set in motion the Invoke, then I go through all contact points and check
  4. // If any of them is at a 45 degree angle or less, if so I cancel the invoke
  5.  
  6. void OnCollisionStay(Collision col) {
  7.         Invoke("Unground", 0.1f);
  8.         foreach (ContactPoint contact in col.contacts) {
  9.             if (Vector3.Angle(contact.normal, Vector3.up) < 45) {
  10.                 CancelInvoke("Unground");
  11.                 grounded = true;
  12.                 Invoke("FrictionOn", 0.2f);
  13.             }
  14.         }
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement