Grappling with grappling hooks

A project we are working on has run into a snare, we have a game based on the functionality of Plant vs. Zombies but with some major differences. The Hero on one side of the screen is charged with taking out bad guys on the other side of the screen, when the bad guys drop a power up or ammo we want the hero to use a grappling hook or "claw" to retrieve item. Also we want the grappling hook to act as a melee weapon as well. We have figured out most of the programming for the grappling hook except it shoots more than one at a time. I know that you can use a constrain attribute to eliminate how many are on the screen at one time, I just don't know how to program it to function properly. How can we get to shoot out, retrieve and retract and only have one on the screen at a time? Any suggestions would be fantastic!
Thanks to everyone in advance!
-P2 Studios

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2014
    8-X
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited February 2014
    You don't use a constrain for this. Make a game attribute boolean called something like game.canShoot and set it to true. Then, you just change it from true to false, like this:

    Actor that shoots grappling hook
    When [condition for shooting the grappling hook] AND attribute game.canShoot is true
         [shoot grappling hook]     
         Change attribute game.canShoot to false

    Grappling hook actor
    When [condition for grappling hook to be completed]
         Change attribute game.canShoot to true

    Or if you know how long the grappling hook takes to complete its actions, you can delete the rules from the Grappling hook actor and instead do this:

    Actor that shoots grappling hook
    When [condition for shooting the grappling hook] AND attribute game.canShoot is true
         [shoot grappling hook]
         Change attribute game.canShoot to false
         Timer after [# of seconds to complete grappling hook action]*
              Change attribute game.canShoot to true

    *make sure to check Run to Completion so that even if the rule conditions above change it will still change the attribute.

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

Sign In or Register to comment.