using UnityEngine;
public class Shoot: MonoBehaviour
{
public Camera cam;
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
shooot();
}
}
void shooot()
{
RaycastHit hit;
if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit))
{
Debug.Log(hit.transform.name);
}
}
The other objects have a box collider and Rigid body. The Raycast detects "Cube1" and after I shoot a raycast at something else and then again shoot a raycast at "Cube1" this code does not detect it. Why?