I’m struggling with this atm. I’m trying to figure out how I can use transform.eulerangles using JS to create a spread attack, like a wave of shots.

this is what I mean. what would be the easiest way to do this? I have a script that spawns a projectile when you push fire (space) and when you have a certain power up, the shot should become this wave effect but I’m not sure how to do it. I saw it done in a tutorial I watched a while ago but I can’t find it now…
Here is what I’ve tried but it doesn’t work how I want it, it spawns the projectiles, all 5 of them (when power up is at level 5) butttt it spawns them all in the same spot soooo its kind of useless.
When you push space bar:
shots = PowLvl;
if (Time.time >= nextShot){
if(wep1 == true && PowLvl == 1){
for(var x : int = 0; x <= shots; x++)
{
Instantiate(wave, Vector3(transform.position.x,transform.position.y + 1,2), Quaternion.identity);
}
nextShot = Time.time + manager.fireRate - manager.fRate;
}
if(wep1 == true && PowLvl == 2){
for(var y : int = 0; y <= shots; y++)
{
Instantiate(wave, Vector3(transform.position.x,transform.position.y + 1,2), Quaternion.identity);
}
nextShot = Time.time + manager.fireRate - manager.fRate;
}
if(wep1 == true && PowLvl == 3){
for(var z : int = 0; z <= shots; z++)
{
Instantiate(wave, Vector3(transform.position.x,transform.position.y + 1,2), Quaternion.identity);
}
nextShot = Time.time + manager.fireRate - manager.fRate;
}
if(wep1 == true && PowLvl == 4){
for(var v : int = 0; v <= shots; v++)
{
Instantiate(wave, Vector3(transform.position.x,transform.position.y + 1,2), Quaternion.identity);
}
nextShot = Time.time + manager.fireRate - manager.fRate;
}
if(wep1 == true && PowLvl == 5){
for(var w : int = 0; w <= shots; w++)
{
Instantiate(wave, Vector3(transform.position.x,transform.position.y + 1,2), Quaternion.identity);
}
nextShot = Time.time + manager.fireRate - manager.fRate;
}
and the script attached to the instantiated shot, wave:
function Update () {
transform.Translate(Vector3(0,speed*Time.deltaTime,0));
if (player == null){
player = GameObject.FindGameObjectWithTag("Player").GetComponent(Player_Script);
}
if(player.wep1 == true){
if (player.PowLvl == 2){
Quaternion.Euler(0,0,30);
dmg = 5;
speed = 6;
}
if (player.PowLvl == 3){
Quaternion.Euler(0,0,30);
speed = 7;
}
if (player.PowLvl == 4){
Quaternion.Euler(0,0,30);
speed = 8;
}
if (player.PowLvl == 5){
Quaternion.Euler(0,0,30);
speed = 9;
}
}
Any tips on any of this mess of code would be appreciated, I’m trying to improve my abysmal scripting skills.
Wow, I like that script! That is exactly what I was looking for. I really need to learn how to do some of these things, switch/case would clean up so many of my scripts in this project...
– asylum101