I have a raycast which is meant to check that an object with the tag “Snake” is under the cursor. I’ve been trying to do some research on this problem, but none of it is making sense or it doesn’t solve the problem. Here’s the code:
if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition),hit,Mathf.Infinity,LayerMask.NameToLayer("Default"))){
Debug.Log("Raycast works");
if(hit.transform.gameObject.CompareTag("Snake")){
Debug.Log("RaycastHit comparison works");
}
}
Neither debug log displays, the objects with the tag have rigidbodies, and I am using #pragma strict. What could be the problem?