Changing gravity

oxigenowoxigenow Member Posts: 17
edited November -1 in Working with GS (Mac)
Hello,

I have an actor with a rule with acceleration (up for jumping). When up is not pressed, actor down to ground slowly.

I´d like to change this; I need when no keys are pressed, actor down to ground quickly and don´t need to wait a lot of for finish to move up before to move down.

Thanks (and sorry my terrible English) ;-)

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Put an acceleration behavior in the actor. set the angle to 270 relative to scene and the speed to 400.

    Then have a rule the says

    when spacebar is pressed (or whatever you want to use to trigger the jump)
    timer - for 1 second
    accelerate 90 to scene, speed of 800

    In the timer if you check run to completion every jump will be the same height, if you don't check the longer you hold the spacebar down the higher he will jump (with a limit of 1 second of course).

    The next question you will likely ask is how to keep the actor from flying if the user rapidly pounds on the spacebar.

    create a boolean game attribute (game.AllowJump)

    Rule in jumping actor - When collides with ground
    change attribute game.AllowJump to 1 (true)

    Then have a rule the says
    when game.allowJump is true
    ------when spacebar is pressed (or whatever you want to use to trigger the jump)
    -----------timer - for 1 second
    ----------------accelerate 90 to scene, speed of 800
    ------OTHERWISE (of the spacebar rule)
    -----------change game.allowJump to 0 (false)

    This system makes it so that when the spacebar is released allow jump is changed to false which means that the actor must land before a second jump can be performed.

    You may think you could just put a rule that says when colliding with ground instead of the whole game.AllowJump thing but there are two problems. You will have to check to the run to completion of the timer so all jumps will be the same height regardless of how long you press spacebar and GS does not have perfect collision detection so you will find sometimes that the actor will not jump at all even though it is on top of the ground actor. So this method works with a high level of consistency.

    Good luck!
  • oxigenowoxigenow Member Posts: 17
    Thanks for your time and help scitunes.

    Great response!

    ;-)
  • eliteelite Member Posts: 26
    Got a question.
    When I do this, my actor either keeps flying upwards, or falling.
    How can I fix this?
Sign In or Register to comment.