Make a weapon wait time after shooting.

Get help using Construct 2

Post » Sat Mar 09, 2013 2:14 pm

I am making a zombie survival platform game, but I have run into a problem where if the player shoots (X), I can repeatedly tap X and a stream of bullets will come out.

Is there an easy way to set a small wait time after each press of X so you cant send out so many? Also, I would like to do the same for a reload time. I have tried to add the wait command to the end of my events but it won't work.

I hope to get an easy solution to this!
B
6
Posts: 8
Reputation: 517

Post » Sat Mar 09, 2013 2:59 pm

how big is the wait command?
maybe you could limit it by limiting how many bullets are on screen.
B
18
S
5
G
4
Posts: 568
Reputation: 5,079

Post » Sat Mar 09, 2013 3:02 pm

There are many threads on timers. Have a search.
ImageImageImage
B
67
S
19
G
124
Posts: 3,214
Reputation: 74,415

Post » Sat Mar 09, 2013 3:02 pm

The wait command is one way, or you could add a timer to your player, which increases/decreases each tick/every x seconds or whatever, and then you can only shoot when the timer has reached a certain value. E.G

Every tick : Player.ShootTimer - 1

On key press :
Player.ShootTimer <=0 : Shoot
                      : Set Player.ShootTimer to 30

That's a coding approach, but the wait command should do the trick anyway.farflamex2013-03-09 15:03:12
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Sat Mar 09, 2013 4:54 pm

Maybe this? What it does is destroy a bullet in flight as soon as the key is pressed but immediately creates one. The created one will stay on the screen until it leaves the layout or the key is pressed.

On key pressed-destroy bullet
              -Create bullet
              -set Speed & direction here
B
14
S
6
G
3
Posts: 71
Reputation: 3,811

Post » Sat Mar 09, 2013 7:46 pm

Hello gamingwithpi,

add a variable to your player that holds the timespan until the next round can be fired. Then in a system event check if time is greater than the time that is stored in your variable. Right after shooting, add the amount of time you wish to wait for the next round to the current time.

if system->time > Player.timeToShoot
--> Player-> spawn Bullet
--> Player set timeToShoot to: time + amount_of_time_to_wait

time is the system expression.

Hope this helps.





B
18
S
2
G
1
Posts: 23
Reputation: 1,448

Post » Wed Mar 20, 2013 4:48 pm

Thanks everyone... I will be trying this out (sorry for the late reply i was on vacation)
B
6
Posts: 8
Reputation: 517


Return to How do I....?

Who is online

Users browsing this forum: zenox98 and 23 guests