Will multiple commands with the same key cancel each other out?
I have a ship which fires weapons when the spacebar is pressed.
I have 2 such code instances, one for if a power up is activated or not.
------
RULE:
When key (Spacebar) is (down)
If (game.powerup) is (false)
DO:
Timer: Every (.2) seconds,
Spawn Actor
Spawn Actor
------
------
RULE:
When key (Spacebar) is (down)
If (game.powerup) is (true)
DO:
Timer: Every (.2) seconds,
Spawn Actor
Spawn Actor
Spawn Actor
Spawn Actor
------
Since adding the 2nd fire code, my ship won't fire.
Should the 2nd set be an "Or Else" set since I'm defining the state of (game.powerup) in the first section?
I have 2 such code instances, one for if a power up is activated or not.
------
RULE:
When key (Spacebar) is (down)
If (game.powerup) is (false)
DO:
Timer: Every (.2) seconds,
Spawn Actor
Spawn Actor
------
------
RULE:
When key (Spacebar) is (down)
If (game.powerup) is (true)
DO:
Timer: Every (.2) seconds,
Spawn Actor
Spawn Actor
Spawn Actor
Spawn Actor
------
Since adding the 2nd fire code, my ship won't fire.
Should the 2nd set be an "Or Else" set since I'm defining the state of (game.powerup) in the first section?
Best Answer
-
tatiang Posts: 11,949
Multiple such commands will not cancel each other out. There is some other reason your ship isn't firing. Please post actual screenshots of your rules because there's likely a small error that I can't spot from the text you posted.
Answers
Weapons 1 fires 2 projectiles with a horizontal spacing from the "nose" of the ship.
Weapons 2 is the power up version and fires 4 projectiles with similar spacing, 2 from "nose" 2 from engine nacelles.
http://i282.photobucket.com/albums/kk248/ZeroRaven87/GS_WEAPONS1_zps51c61732.png
http://i282.photobucket.com/albums/kk248/ZeroRaven87/GS_WEAPONS2_zps13b2a683.png
I assume you're using timers because you want auto-fire, where the player holds the space bar down and bullets continually spawn? Otherwise, no need for timers.
If that wasn't the problem, try deleting the actor from the scene and re-adding it. It could be related to prototype/instance issues.
Well oddly enough after posting the reply with the attached images, I went ahead, reloaded the project in GS, and it was working. May have just been a glitch in the tester/viewer?
Hi @ZeroRaven Try this:
RULE:
When key (Spacebar) is (down)
Nested in above rule When (game.powerup) is (false)
Timer: Every (.2) seconds,
Spawn Actor
Spawn Actor
Otherwise
Timer: Every (.2) seconds,
Spawn Actor
Spawn Actor
Spawn Actor
Spawn Actor
------
I think it was just a glitch in the GS Windows versions preview mode. It seems as if I press keys too fast it may not work right away.