So I’m making an fps game but I’m having a hard time creating bullet spread. I used brackeys tutorial for shooting but he never showed how to make bullet spread (either that or I’m dumb and didn’t listen). here is my shooting script: (and I don’t have any spread code on it because nothing has worked)
void Shoot()
{
currentAmmo--;
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(damage);
}
if (hit.rigidbody != null)
{
hit.rigidbody.AddForce(-hit.normal * impactForce);
}
Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
}
}
I hope someone has an answer.