Shooter, double shot power up scripting problem.

Hi,

I am making a top down shooter and i can’t seem to make the power up collection work properly.

I have a power up falling from the top of the screen and when the player collects it, their shooting power goes from a single shot to a double shot.

The things that work are the power up moving down the screen and it can be collected, but the double shot never happens it stays as a single shot.

function SecondShot ()
{
	if (gameObject.tag == "double shot")
	{
		//Create a second bullet.
		if(Input.GetKeyDown(fireKeyInput))
		{
		Instantiate (projectile, socketProjectile2.position, socketProjectile2.rotation);
		audio.Play();
		}
	}
}

I placed SecondShot (); inside the function update () and play the game, i can shoot the single shot and collect the power up for the double shot, but the double shot does not work.

if i place // in front of if (gameObject.tag == “double shot”) as well as the two { } it is contained in and then run the game i have the double shot from the start and still can collect the double shot power up.

can anyone shed some light on where it is i am going wrong?

Thanks in advance.

Chobi.

var doubleShot : boolean =false;

Then on collision, set it to true.

Finally, where you fire your bullets, put:

if(doubleShot)
{
//fire second bullet
}

Thanks, i think i got a bit further with your help. :slight_smile:

the main problem i am having is that the line if (gameObject.tag == “double shot”) stops the function of the double shot, if i // it out the double shot works, but i need it so that when i collect the double shot power up, its supposed to trigger the double shot, but it does not work.

I am not sure where to go from here with the code.