My raycasting isn't working
I am trying to make an fps. I recently learned Unity and am trying to raycast but its not working for some reason. If someone could explain why it isn't working I would really appreciate it. Since I did just start learning Unity I was hoping to get an explanation in simple words as I don't yet understand complex Unity topics. Here is my Code:
 using UnityEngine;
 using System.Collections;
 
 public class PlayerShoot : MonoBehaviour
 {
 
     public PlayerWeapon weapon;
 
     [SerializeField]
     private Camera cam;
 
     [SerializeField]
     private LayerMask mask;
 
     void Start ()
     {
         if (cam == null)
         {
             Debug.LogError("PlayerShoot: No Camera referenced");
             this.enabled = false;
         }
     }
 
     void Update ()
     {
         if (Input.GetMouseButtonDown(0))
         {
             Shoot();
         }
     }
 
     void Shoot ()
     {
         RaycastHit _hit;
         if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, 200))
         {
             Debug.DrawRay(cam.transform.position, cam.transform.forward * 200);
             Debug.Log("It Works!");
         }
     }
 
 }
               Comment
              
 
               
              Answer by Aggerwal · Jun 26, 2016 at 08:38 PM
Maybe the other thing you are trying to hit does not have a collider component?
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                