Hello there.
Can anyone of you help me with this situation? It seems like my Physics2D.Raycast() is not working at all.
Whenever I try to Debug.Log() the name of the hit object by the raycast, I’m getting a null reference. I am using a LayerMask named “raycastMask” as my filter when raycasting. Currently it is set to “Everything”.
Information on the GameObject I’m trying to perform a raycast on:
[Layer and tag]
-
Layer: “Ground”
-
Tag: “Ground”
[Components]
-
Collider: Polygon Collider 2D
-
Rigidbody: Rigidbody2D (Kinematic)
I’ve tried to used RaycastAll(), which works (don’t know why), but I want to avoid using that.
To me, it looks like everything is fine, but its apparently not! Can anyone of you tell me what I’m doing wrong? I’ve been debugging this for like an one and a half hour now…
Also, nevermind the missing }
, its there in the actual code.
Thanks!