How can I make an actor jump with a button?

dondan89dondan89 Member Posts: 150
edited January 2012 in Working with GS (Mac)
Hello,


How can I make an actor jump with a button?


Thank You

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    make a attribute called jump.

    Have a rule in the button when touch is pressed:
    -change attribute jump to true
    then open up the otherwise section of that rule and have a change attribute behavior changing attribute jump to false

    then in the actor you want to jump have a rule when attribute jump = true
    -change attribute self motion linear velocity y to 400 (adjust the 400 to change the jump height

    just make sure to have a accelerate behavior in the down direction in the actor you want to jump to act as gravity
  • LeonardDeveloperLeonardDeveloper Member Posts: 4,630
    Make attribut bounce
    Rule when touch is pressed change attribute bounce to true
    Otherwise false
    Then when the attribute > true adjust his linear velocity to height of jump!
    Edit: @johnpapiomitis you beat me to it! :D
  • dondan89dondan89 Member Posts: 150
    Hi,


    Thanks for the respond, can you make me small template about this?


    thank you
  • LeonardDeveloperLeonardDeveloper Member Posts: 4,630
    We'll I'm not home.... But in my own opinion I know it sounds easier if someone else does the work for you, but your not going to be able to learn if you don't do it yourself.....
    I reaky am sick of people asking for free templates now.... Just my two cents! :)
    If you really want to make an actor jump go buy a DBA template (plat former one) from http://www.Deepblueapps.com
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    did you try it?
  • dondan89dondan89 Member Posts: 150
    yes, I do have going left and going right and works find, but the problem with jump is that it goes up and then it does not go back down as normal jump
  • LeonardDeveloperLeonardDeveloper Member Posts: 4,630
    Oh then you might want to put a timer like... When game.bounce > true after .2 seconds change attribute game.bounce to false! :) hope that helps!.
  • LeonardDeveloperLeonardDeveloper Member Posts: 4,630
    edited January 2012
    Edit: removed for double post.... Gs really need to work on the forum compatibility with iPads and iPhones...... :)
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    no need for a timer, since a change linear velocity is a one time thing not a constant movement

    if the actor is not going back down, then you did not put the accelerate down behavior to act as gravity as a posted above

    cheers
  • dondan89dondan89 Member Posts: 150
    edited January 2012
    Ok I will try
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Did you add gravity?
  • dondan89dondan89 Member Posts: 150
    no
Sign In or Register to comment.