Skip to content

Instantly share code, notes, and snippets.

@justonia
Created March 31, 2017 21:37
Show Gist options
  • Save justonia/d43813811e4c17608dbd862a47692b73 to your computer and use it in GitHub Desktop.
Save justonia/d43813811e4c17608dbd862a47692b73 to your computer and use it in GitHub Desktop.
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