I am working on a gun script in my game and I am using raycasting currently to shoot. So when I am instantiating the impact prefab, it is putting it right where the raycast hit and I am trying to figure out how to offset the instantiated object so instead of being directly on the object, it hovers a little bit away from the object.
This is a snippet of my code
void Shoot()
{
ammo--;
RaycastHit hit;
Transform cam = GameObject.FindGameObjectWithTag("MainCamera").transform;
if (Physics.Raycast(cam.position, cam.forward, out hit, 1000))
{
Instantiate(impactPrefab, hit.point, Quaternion.FromToRotation(-transform.forward, hit.normal) * transform.rotation, null);
}
}
if you can help out, thank you.