I’m trying to give shotgun dispersal but I don’t know how to edit it to make it work?
public int NumberOfPellets = 5;
public float ShotRadius = 0.05f;
public GameObject DecalHoleC;
public Transform Barrel;
public GameObject DecalHoleM;
public GameObject DecalHoleG;
public GameObject DecalHoleB;
public GameObject DecalHoleW;
protected override void OnFire(Vector3 dir)
{
for (int i = 0; i < NumberOfPellets; i++)
{
var xy = Random.insideUnitCircle * ShotRadius;
var newDirection = dir + transform.TransformDirection(xy);
FireBullet(newDirection);
Ray rayorigin = new Ray(Barrel.position, Barrel.forward);
RaycastHit hitinfo;
if (Physics.Raycast(rayorigin, out hitinfo))
{
if (hitinfo.collider.tag == "Concrete")
{
GameObject bulletUse1 = DecalHoleC;
Instantiate(DecalHoleC, hitinfo.point, Quaternion.LookRotation(hitinfo.normal));
Vector3 direction = hitinfo.point - Barrel.position;
Barrel.rotation = Quaternion.LookRotation(direction);
Destroy(DecalHoleC, 4);
}