I'm trying to make a 2D platform game where my character makes a ground check before jumping using Physics2D.BoxCast
& some of the platforms have Capsule Collider 2D
& others have Box Collider 2D
. Everything works fine with the Box Collider but when it comes to Capsule Collider, Boxcast is not responding & my character can spam jump on those platforms. Here's my code for ground check,
public bool isGrounded()
{
RaycastHit2D raycastHit = Physics2D.BoxCast(coll.bounds.center, coll.bounds.size, 0f, Vector3.down, castDist, ground);
return raycastHit.collider != null;
}
How can I resolve this issue? Any way to detect both BoxCollider & CapsuleCollider?
question from:
https://stackoverflow.com/questions/65642802/boxcast-not-working-with-capsule-collider-2d-in-unity 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…