laser.SetActive(true);
StartCoroutine(Laser());
AmmoBox.currentAmmoLaser = AmmoBox.currentAmmoLaser - 70f;
recoil.Fire();
RaycastHit hit;
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
{
Debug.Log(hit.transform.name);
Target target = hit.transform.GetComponent<Target>();
if (target != null)
{
target.TakeDamage(damageLaser);
Debug.Log(damageLaser);
}
if (hit.rigidbody != null)
{
hit.rigidbody.AddForce(-hit.normal * impactForce);
}
GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
Destroy(impactGO, 3f);
This only hits the first object it collides with