how to make actor jump not fly

bigoldeebigoldee Member Posts: 5
edited November -1 in Working with GS (Mac)
Hi, I am creating a platform game using the template and would like my actor to jump and be able to jump again only when he touches the ground or another object. Currently what happens is that if you press the space bar repeatedly the actor can fly because it keeps jumping even in mid-air. If someone knows a solution I would greatly appreciate it.Thanks

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    As you are about to jump, you can make a check if it is colliding with the ground. There is a little more than that to make it look better, and I will put that in the how-to's.
  • nulonulo Member Posts: 315
    this is what i did to make it work:
    http://img.photobucket.com/albums/v451/LotusHurt/jumprule.png

    *create the "jump" attribute as a boolean and set it to false as default (this way the game knows that the character should not be jumping when the game starts.)
  • bigoldeebigoldee Member Posts: 5
    Thanks for the help guys. I ended up copying nulo's jumprule and it worked.
    I didn't make the jump attribute as a boolean and it still works well.
    Thanks again
  • bigoldeebigoldee Member Posts: 5
    Hmm, nulo's solution seemed to work but it's not anymore.
    If anyone has any other suggestions I would like to hear them.
    The problem I am having is just like in the platform game demo, if you repeatedly
    press jump your actor will fly.
    Thanks.
  • nulonulo Member Posts: 315
    your actor will only fly if he is colliding with a ground (used as a wall) or if he is touching a ground piece thats over his head (ground pieces in the air).
    thats because every time you collide with the "ground" your "jump" variable gets back to 0 and lets you jump again.
  • JGary321JGary321 Member Posts: 1,246
    I was thinking about this, you could make the ground as 1 actor then the walls as another actor. you can make "platforms" as 2 different actors, one directly on top of the other, so they look like 1 actor. The bottom of the platform would be a "wall actor" the top would be your ground actor, so you still could only jump when your on top of the platform. EX:

    ======= ============

    ============== ===============

    The top dash would be ground actor, bottom dash wall actor.
    So when you jump up & hit the bottom of the next platform it would not let you jump again. Hope this helps.
  • FreztinoFreztino Member Posts: 30
    Hello now I need help with jumping...
    I tried to do what you said but I can't get my actor to fall down again...
    What am I doing wrong

    From Freztino =)
  • JGary321JGary321 Member Posts: 1,246
    Hey Freztino, I've never created any actors that jump, so I don't know off hand. I would take a look at the games that come with the program. They have a game in their that shows how to make a character jump. That would probably be a big help.

    -JGary
  • nulonulo Member Posts: 315
    did you put a value larger than 0 on the gravity attribute? a good start is 300.
  • FreztinoFreztino Member Posts: 30
    Aaah i knew it was some with gravity because i saw it but i could find, so i fonud it now =)

    Thanks for the help!

    From Freztino =)
  • ap1337ap1337 Member Posts: 5
    I have the same problem that freztino had, but in my case, when I add gravity the whole picture just disapear in the lower left corner. How can I fix this?
Sign In or Register to comment.