I’m trying to write a simple script to cast a ray from a gun object to whatever object/point the player clicks on. Right now, it doesn’t show any errors, but it doesn’t draw the ray or give me the debug.log message it’s supposed to. Here is the code:
void Update ()
{
if(Input.GetMouseButtonDown(0))
{
RaycastHit hitInfo;
if (Physics.Raycast(transform.position, Vector3.forward, out hitInfo, range))
{
Debug.Log("You are shooting");
Debug.DrawRay(transform.position, hitInfo.point);
}
}