Fire delay when looping through gamepads?

Get help using Construct 2

Post » Fri Jan 03, 2014 7:43 am

Why would the or block have to be checked every tick, when it can only affect anything every player.fireratio seconds?

Or are you planning to add more code to the block?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Jan 03, 2014 5:09 pm

[QUOTE=LittleStain] Why would the or block have to be checked every tick, when it can only affect anything every player.fireratio seconds?

Or are you planning to add more code to the block?[/QUOTE]

Yep, the second one. Also, since the player can begin firing at any time, having the gamepad input checked in the OR block under the timer could mean a delay in the projectile firing.

I tried mapping this player input control to a button, and it works fine with the timer (without setting the projectile direction, obviously) - but not the analog stick. I'm almost wondering if it's a bug in the gamepad controller behavior now.digitalsoapbox2014-01-03 17:18:54
B
70
S
40
G
24
Posts: 518
Reputation: 20,070

Post » Sat Jan 04, 2014 9:56 am

The OR block seems fine to me.

Instead of Every X Seconds try giving the Player a new variable (Player.CanFire boolean start true) and check/set that when they fire.

for each Player
check gamepad OR block
      if Player.CanFire == true then
        Set Player.CanFire = false -- so they can't fire again yet
        Do your normal firing stuff
        Wait Player.projectileFireRate seconds -- adds delay between firing
        Set Player.CanFire = true -- lets player fire again


OddConfection2014-01-04 09:58:25
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
32
S
9
G
7
Posts: 444
Reputation: 6,731

Post » Sun Jan 05, 2014 9:30 pm

[QUOTE=OddConfection] The OR block seems fine to me.

Instead of Every X Seconds try giving the Player a new variable (Player.CanFire boolean start true) and check/set that when they fire.

for each Player
check gamepad OR block
      if Player.CanFire == true then
        Set Player.CanFire = false -- so they can't fire again yet
        Do your normal firing stuff
        Wait Player.projectileFireRate seconds -- adds delay between firing
        Set Player.CanFire = true -- lets player fire again


[/QUOTE]

That does it, but if there's any kind of drop in framerate the weapon doesn't fire. Why Every X works different than Wait X is a bit confusing. Still though, a step in the right direction.

Thanks!
B
70
S
40
G
24
Posts: 518
Reputation: 20,070

Previous

Return to How do I....?

Who is online

Users browsing this forum: Darth Crusher, David181, vaticant and 2 guests