how to make character jump via another actor

HDIMappsHDIMapps Member, PRO Posts: 18

I have three arrows. The left arrow moves my character left and the right arrow moves my character right. Those were the easy ones. My problem is with the up arrow. I want it to make my character jump (and only when in contact with the floor), but I can't seem to get it to work. Any help would be great!

Comments

  • Think through what Gamesalad is needing to know to accomplish this, you laid it out pretty well now just think of what that sounds like in Gamesalad logic

    I assume your up arrow changes a game attribute such as Game.Up

    when pressed change attribute Game.Up to true, otherwise change to false

    then in your actor a rule like this

    if actor overlaps or collides with ground, AND, Game.Up is true
    change self.linearvelocity.y to 300 (or some amount)

  • HDIMappsHDIMapps Member, PRO Posts: 18

    Yes. I have two game attributes, characterSpeed and characterDirection. When I first set things up, I used the controls on my keyboard and when I pressed the up and right/left arrows on my keyboard, my character made a nice arc. I did this by following the directions on one of the intro course modules (e.g. changing attributes of x velocity and y velocity, instead of using the "move" function). When I changed controls from the keyboard to touching other actors (the arrows) things got funky.

    So, I have things set up, as you mentioned...where if character is colliding with ground the characterOnGround attribute is set to "1" otherwise, it's set to "0".

    Then, I have if the up arrow is touched AND the characterOnGround attribute is set to 1, change the characterSpeed and characterDirection accordingly, otherwise, bring the character back to earth.

    However, as soon as the character breaks contact with the ground, the second portion of the rule (attribute = 1) is no longer true and so the character immediately come back down just as fast as he jumped up. The effect looks like he's hopping on steroids.

    If I remove the condition to be in contact with the ground, then the character will continue floating up while the up arrow is pressed.

  • HDIMappsHDIMapps Member, PRO Posts: 18

    oh happy day. it only took me three hours but I figured it out. had to constrain y velocity only if the character was on the ground

  • claycollins33claycollins33 Member, PRO Posts: 8

    @HDIMapps said:
    Yes. I have two game attributes, characterSpeed and characterDirection. When I first set things up, I used the controls on my keyboard and when I pressed the up and right/left arrows on my keyboard, my character made a nice arc. I did this by following the directions on one of the intro course modules (e.g. changing attributes of x velocity and y velocity, instead of using the "move" function). When I changed controls from the keyboard to touching other actors (the arrows) things got funky.

    So, I have things set up, as you mentioned...where if character is colliding with ground the characterOnGround attribute is set to "1" otherwise, it's set to "0".

    Then, I have if the up arrow is touched AND the characterOnGround attribute is set to 1, change the characterSpeed and characterDirection accordingly, otherwise, bring the character back to earth.

    However, as soon as the character breaks contact with the ground, the second portion of the rule (attribute = 1) is no longer true and so the character immediately come back down just as fast as he jumped up. The effect looks like he's hopping on steroids.

    If I remove the condition to be in contact with the ground, then the character will continue floating up while the up arrow is pressed.

    Going to give this a shot, having a bit of the same trouble.

Sign In or Register to comment.