I have a weapon firing using raycast, when i click the mouse it fires, but the muzzle flash only appears when im pointing it at a target.
any suggestions as to why this happens?
the shoot section of the code
void Shoot()
{
RaycastHit hit;
if (Physics.Raycast (fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
{
Debug.Log (hit.transform.name);
Instantiate (flash, flashSpawn.position, flashSpawn.rotation); //addition
Target target = hit.transform.GetComponent();
if (target != null)
{
target.TakeDamage(damage);
}
}
}
}
↧