Detect a kinematic rigidbody collision with a static rigidbody using Collider2D.IsTouchingLayers
I have a tilemap called Moving Platform and attached to it is a kinematic rigidbody. Further, there is a foreground tilemap with a layermask "Ground" assigned to it. The scene arrangement is shown in the screenshot below:
Components attached to the platform are shown below:
Components attached to the foreground are shown below:
The highlighted platform moves to right and collides with the foreground. I am trying to detect this collision in my Update() function, but the debug log always says false Debug.Log(myCollider.IsTouchingLayers(LayerMask.NameToLayer("Ground")));
How do I detect the collision between the two tilemaps?
Your answer
![](https://koobas.hobune.stream/wayback/20220612170248im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Select all layers in the scene except the triggers 0 Answers
Collider2d cast to player child ignores the child 0 Answers
RayCastAll seemingly ignoring a particular collider 0 Answers
Making raycast ignore multiple layers 6 Answers
Multiple interior collision spaces/pocket collision dimensions. 1 Answer