how to make player only have certain number of bullets to shoot?

Hi, I'm making a game where one player1 spawns out bullets that player2 can collect to shoot. I need help with how to make it so the bullets disappear if not collected by player2, and how to make it so player2 only can shoot what it collects. Thanks for any help!

Best Answers

  • IsabelleKIsabelleK Posts: 2,807
    Accepted Answer
    Not sure if this is want you want - make two integer attributes - game.ammo1, and game.ammo2.
    If player shoots, change game.ammo1 (for player 1), or game.ammo2 (for player 2), to game.ammo1, or game.ammo2 -1.
    If player overlaps, or collides with ammo crate, change attribute game.ammo1, or game.ammo2 to game.ammo1, or game.ammo2 +X (number of bullets collected).
  • tatiangtatiang Posts: 11,949
    edited May 2013 Accepted Answer
    bullet actor:
    Timer after [some number] seconds
         Destroy actor

    player2 actor:
    When actor collides with [bullet actor]
         Change Attribute game.bulletCount to game.bulletCount+1
    When [all] [condition for shooting, such as key pressed] is true AND attribute game.bulletCount>0
         [spawn shootingBullet actor]

    shooting bullet actor:
    When [any] actor collides with [enemy actor] OR self.Time > [some number]
         Change Attribute game.bulletCount to game.bulletCount-1
         Destroy Actor

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Answers

Sign In or Register to comment.