Hi everyone,
Im trying to make a shrapnell shell that when it hits anything it explodes, spraying out 30 odd bullets in a sphere.
It sort of works, I added a bulet spawn point and have it point in a random direction for each bullet. for some reason the bullets group along 1 line, I can’t seem to fix it. Any ideas??
using System.Collections;
using UnityEngine;
public class Shrapnell : MonoBehaviour {
public Transform shrapnelSpawn;
public int power = 20;
public int projectiles = 30;
public GameObject bulletPrefab;
private void OnCollisionEnter(Collision col)
{
for (int i = 0; i < projectiles; i++)
{
var bullet = Instantiate(bulletPrefab, shrapnelSpawn.position, shrapnelSpawn.rotation);
shrapnelSpawn.rotation = Random.rotation;
bullet.GetComponent<Rigidbody>().velocity = bullet.transform.forward * power;
Destroy(bullet, 1.0f);
}
Destroy(gameObject);
}
}
