Last active
March 31, 2017 21:32
-
-
Save justonia/4d2d36eadf88cc0dd20b0eb694b73f55 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; | |
// CapsuleCollider only has local space center/height/radius properties | |
// and OverlapCapsule expects world space start/end/radius. | |
Vector3 point0 = ???; | |
Vector3 point1 = ???; | |
float radius = ???; | |
var colliders = Physics.OverlapCapsule(point0, point1, radius); | |
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