Created
March 31, 2017 21:37
-
-
Save justonia/d43813811e4c17608dbd862a47692b73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IsOverlappingBehavior : MonoBehavior | |
{ | |
public CapsuleCollider capsule; | |
public bool IsOverlapping { get; private set; } | |
private void Update() | |
{ | |
IsOverlapping = false; | |
// Converts the capsule into world-space parameters and calls | |
// Physics.OverlapCapsule for you. | |
var colliders = PhysicsExtensions.OverlapCapsule(capsule); | |
foreach (var collider in colliders) { | |
if (collider != capsule) { | |
IsOverlapping = true; | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment