attribute change while touching button doesnt work

Simply put it (a ship is shooting bullets, when it picks up a boost it should shoot faster but it does not)

when i'm touching a button the ship is shooting bullets in each (0.3*bulletrate) seconds
where bulletrate = 1 so it shoots every 0.3 seconds

now when the shooting actor collides with the boost actor
ill change bulletrate to 0.5 so it should shoot (0.3*0.5=0,15) times per second but it does not

its still shooting at the same rate of fire
only when I release the button and touch it again it changes

how to avoid this kind of a behaviour?

Ive tried to re-spawn the button and destroy the old one but that wasn't working, now i'm out of ideas

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi @nizzar27 Where in your Rules is your Change Attribute behaviour? Also, I presume your bullets are being spawned?

    Either way, it'd be best if you gave a bit more info on your programming, so could you post the Rules/behaviours associated with your bullet shooting, and include the rule where you change the bullet rate...then we'll be able to get to grips with your problem.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • nizzar27nizzar27 Member Posts: 8
    -Button-

    RULE
    IF Game.CanShoot is true
    DO
    Spawn Actor bullet
    SET Game.CanShoot to false
    END

    RULE
    IF Game.CanShoot is false
    DO
    Timer->EVERY (Game.BulletsRate*0.3) Seconds Run to complition - false
    SET Game.CanShoot to true
    END

    -Boost Actor-

    RULE
    IF Collides with ship
    DO
    SET Game.BulletRate to 0.5
    END


    Bulletsrate is set to 1 as default
    CanShoot is set to true as default

    BulletsRate changes only after releasing button and touching it again
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2014

    Thanks for posting more info. I'm not sure why you're using a loop there...unless that's the way you're trying, to interrupt the Timer when BulletRate changes... that's your problem as you can't interrupt it that way, I'm thinking...

    OK, so try this, to see if it works as you want (assuming a start value of CanShoot as false):

    -Button-

    RULE
    IF touch is pressed
    DO
    Change Attribute Game.CanShoot to true
    END

    RULE
    IF touch is released
    DO
    Change Attribute Game.CanShoot to false
    END

    RULE
    IF Game.CanShoot is true
    DO
    Timer->EVERY (Game.BulletsRate*0.3) Seconds Run to completion
    Spawn Actor bullet
    END

    -Boost Actor-

    RULE
    IF Collides with ship
    DO
    SET Game.CanShoot to false
    SET Game.BulletRate to 0.5
    Timer->After 0.2 Seconds Run to completion --- you might not need this delay
    SET Game.CanShoot to true
    END

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • nizzar27nizzar27 Member Posts: 8
    thx you for your post

    the button code u sent wasnt good for me :)

    but the boost code
    stop shooting, change bulletrate, timer 0.1 start shooting
    helped

    thank you very much
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2014

    OK, I got some right then... ;-) You're welcome & pleased it's OK for you now. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.