Hello everyone,
i was trying to create a different shooting “system”, i basically used to do this by creating a for loop that iterate between all the bullets in a single shot, then based on the counter i add an amount to the current angle so i have a nice looking multiple bullets shot, i tried to do the same algorithm with unity and like always, the result is pretty fancy but not what i really want, i wrote this method to shoot bullets :
private Transform myTransform;
public GameObject Bullet; // bullet prefab
void shoot (float reload, int num, float distance)
{
tmpReload += 0.1f;
if (tmpReload >= reload) {
print (tmpReload);
for (int i =0; i<num; i++) {
Quaternion target = Quaternion.Euler (i * distance, 0, 0); // this line is wrong, but i thought this is where i should do it
Bullet.transform.rotation = target;
Instantiate (Bullet, myTransform.position, Bullet.transform.rotation);
}
tmpReload = 0;
}
}
the result i want to achieve is a pretty basic for any 2D shooter game so i think the solution must be quite easy,
PS :
i tried to do this :
Bullet.transform.rotation = Quaternion.Slerp (transform.rotation, target, Time.deltaTime * smooth);
but also i didn’t have the result that i was looking for
thank you very much