Unity 3D Raycast

PHOTO EMBED

Sat Jan 15 2022 11:48:35 GMT+0000 (UTC)

Saved by @AnotherFrog #c#

        RaycastHit hit;
        // Does the ray intersect any objects excluding the player layer
        if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity, layerMask))
        {
            Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow);
            Debug.Log("Did Hit");
        }
        else
        {
            Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 1000, Color.white);
            Debug.Log("Did not Hit");
        }
content_copyCOPY

https://docs.unity3d.com/ScriptReference/Physics.Raycast.html