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?

Best Answer

  • tatiangtatiang Posts: 11,949
    Accepted Answer
    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

  • ZeroRavenZeroRaven Member Posts: 33
    Ok attached is the screenshots of the firing code.
    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
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    When game.powerup is true, you have the two spawn behaviors outside of a timer. Shouldn't those be inside of a timer?

    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.
  • ZeroRavenZeroRaven Member Posts: 33
    edited August 2013
    If you look closely, the two open spawns (the ones added for the powerup) are inside the same .2 timer as the initial 2. So that wasn't an Issue.
    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?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    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
    ------
  • ZeroRavenZeroRaven Member Posts: 33
    Gyro I will try your suggestion, it seems a slightly easier version of my coding. dunno why I cant just simplify my own coding lol.
    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.
Sign In or Register to comment.