raycast doesn't collide on anything? (C#)

I’ve been reading around to try solving this problem, basicly what I’m trying to do is to raycast from maincamera to an object with a certain tag, and return an info (for now I just use print for debugging), but it doesn’t get back anything, the script compile fine without errors of any sort, so I don’t know where to look. Here the code:

using UnityEngine;

public class raycast_item : MonoBehaviour {

public float RayLength  = 1.0f;

void Update() {
        RaycastHit hit;

         
        if(Physics.Raycast(transform.position, Vector3.forward, out hit, RayLength))
        {
        if (hit.collider.gameObject.tag == "Item") 
        {
            print ("Item");
        }
        else
        {
            print ("Nothing");
        }
    }
}

}

Use Debug.DrawRay to visualize what you’re doing. In this case it’s likely you meant transform.forward and not Vector3.forward.

fromCamToTarget = targetTransform.transform.position - camTransform.transform.position;

	if (Input.GetButton("Fire1"))
	{
		if (Physics.Raycast(camTransform.transform.position, 
			fromCamToTarget,
			out bulletHit,bulletDistance))
			
			{	
				if (bulletHit.collider.gameObject.tag == "target")
				{
					Debug.DrawRay(camTransform.transform.position,
					(targetTransform.transform.position - camTransform.transform.position), 
					Color.green);
					Debug.Log(bulletHit.collider.gameObject.tag);
				}
				
				else
				{
					
					Debug.Log(bulletHit.collider.gameObject);
					Debug.DrawRay(camTransform.transform.position,
					fromCamToTarget, 
					Color.red);
				}
				
			}
				
		
		
	}