- Home /
Question by
UltraAlucha · Aug 24, 2021 at 03:33 PM ·
programmingcollision detectioncastcasting
Boxcast not detecting tilemap/composite collider
I'm using Physics2D.BoxCast() method in order to detect whether the player is touching the ground or not. But it's not working on the tilemap.
I am detecting ground on groundLayer specifically. I took another object, specified groundLayer, gave it boxcollider and it works on it. Then I understood the problem here is contacting between tilemap and physics2D.boxcast
private bool c_OnGround(){
RaycastHit2D raycastHit = Physics2D.BoxCast(boxCollider.bounds.center,boxCollider.bounds.size, 0f, Vector2.down, 0f, groundLayer);
Debug.DrawRay(boxCollider.bounds.center, Vector2.down, Color.red);
return raycastHit4.collider != null;
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613042115im_/https://answers.unity.com/themes/thub/images/avi.jpg)