how do i make the actor jump?

snowstormsnowstorm Member Posts: 51
edited November -1 in Working with GS (Mac)
i am starting on a platformer and and i came to the part where you would have to jump... so i was wondering how to do that.

Comments

  • youngster9youngster9 Member Posts: 326
    change attribute motion linear velocity y
    I don't know exactly which attribute it is but just look for linear velocity y under motion.

    That should work
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    make a interger attribute called jump

    in your jump button have a rule when touch is pressed
    -change attribute jump to 1
    then go into the otherwise section of that rule and put a change attribute behavior in there changing attribute jump to 0

    So everytime you press the jump button attirubte jump changes to 1, then when you let go (otherwise) it changes back to 0

    And lastly in your player have a rule when attribute jump=1
    -change attribute self.motion.linear.velocity.y to 300

    cheers
  • snowstormsnowstorm Member Posts: 51
    ok, so i changed the linear velocity to -150 and the actor fell when i released the key. but i only want to be able to jump a certain hight, so...
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    yes it fell because you changed it to -150. Thats telling it to move down. ANything negative is a down movement, and positive is up (on motion linear y) start with 300 like i said. If thats to much make it smaller. But it has to be over 0 to jump
  • snowstormsnowstorm Member Posts: 51
    Ok, thank you very much! it is working! thank you!
  • snowstormsnowstorm Member Posts: 51
    now i have one more problem, every time i press the jump button -even if the actor is in the air- it still jumps higher. anyone know how to fix that?
  • svnsvn Member Posts: 445
    Yeah, your actor thinks that-since no indication is given of WHERE/WHEN it should to jump- no matter when or where it is, when Jump is pressed, it should move upwards at a rate of 300. To counteract this, add a boolean Game attribute called Grounded. Give the actor a rule that when it collides with the ground, change attribute GRounded to True, otherwise, change attribute Grounded to false. Now, in the jump behavior, add an additional clause that tells it when jump is pressed AND game.attribute.grounded= true, change attribute self.motion.linear.Y. to (anypositivenumber). In the otherwise behavior, (if gravity is not ALREADY set in the Game attributes) add a Move behavior that tells it to move downwards. Hope it helps!
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Put your jump rule in another rule when actor overlaps with ground. That way the jump can only be triggered if the actors on the ground.

    Also for your gravity put a accelerate down (relative to scene) behavior by itself in the player. It'll make it more realistic and better physics then putting a move down behavior in the otherwise
Sign In or Register to comment.