Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Invoking Unground sets grounded to false
- // CancelInvoke stops it from happening
- // First I set in motion the Invoke, then I go through all contact points and check
- // If any of them is at a 45 degree angle or less, if so I cancel the invoke
- void OnCollisionStay(Collision col) {
- Invoke("Unground", 0.1f);
- foreach (ContactPoint contact in col.contacts) {
- if (Vector3.Angle(contact.normal, Vector3.up) < 45) {
- CancelInvoke("Unground");
- grounded = true;
- Invoke("FrictionOn", 0.2f);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement