Jumping help!!

Ok i have on screen controls and I have a button for jumping, my problem is unless that button is held in the jump and animation is cut way short!! I want to work when pressed not held down! Help please?!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited September 2018

    If [button is pressed]
         Timer after 0 seconds [with Run to Completion CHECKED]
              Animate

    To explain, Run to Completion forces behaviors (in this case, Animate) to complete regardless of the status of the rule condition.

    Another way to do this:

    If [button is pressed]
         Change attribute game.animate to true

    If attribute game.animate is true
         Animate
     
    If self.Image = [last frame of animation]
         Change attribute game.animate to false

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

  • crazymooseappscrazymooseapps Member, PRO Posts: 30

    So would this code go under the button or under the player animation? Im assuming player animation?

  • crazymooseappscrazymooseapps Member, PRO Posts: 30

    But also it appears the height of the jump is tied to length of time button is held in, how to correct that?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @crazymooseapps said:
    So would this code go under the button or under the player animation? Im assuming player animation?

    If your button actor and player actor are separate, then make a game attribute of type boolean called game.animate and try this:

    button actor
    If [button is pressed]
    Change attribute game.animate to true

    player actor
    If attribute game.animate is true
    Animate

    If self.Image = [last frame of animation]
    Change attribute game.animate to false

    I'm not sure about the jump height. It depends how you have your rules set up.

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

  • crazymooseappscrazymooseapps Member, PRO Posts: 30

    I appreciate the help! Worked like a charm! I will fogure out the height by messing around lol

Sign In or Register to comment.