Jump High in Relation to Key Hold Duration

KamazarKamazar Member Posts: 287
edited November -1 in Working with GS (Mac)
I remember there being an entry in the wiki for this but all I find is the simple "accelerate upward for X seconds" solution. How do I get it so the height is related to how long I hold the key? Thx.

Comments

  • harrioharrio Member Posts: 234
    what's cooking,

    i think you can use a keypress rule instead of a timer setup. but then you'll have to pay close attention to max speed stuff.
  • JGary321JGary321 Member Posts: 1,246
    Hrmm. Have you tried what Harrio said? For instance:

    When key "space" is pressed:

    accelerate up.

    If so what did it do?
  • KamazarKamazar Member Posts: 287
    It... goes up? I'm using a key press rule, but there's nothing to keep the player from continually pressing it making the actor fly. I've tried setting up another rule that fixes this, but the behaviors keep on overriding each other. I need my player to jump, slow down when either the max height has been reached or the key has been let go, and then start accelerating downwards. I can't get anything that works 100%.
  • JGary321JGary321 Member Posts: 1,246
    Good point about the "fly" thing. Try this (this is theory, haven't tried it),

    Set the acceleration on a timer. That way there is a max they can hold it. Then try something like this as the rule

    IF
    If space key is down
    If game. "Jump" (Boolean) = 0

    THEN
    Accelerate ... (whatever you have)
    Change game. "Jump" = 1

    Then as another rule.

    IF
    Actor recieves event collides with (select ground actor, or use the new tag feature)

    THEN
    change attribute game.jump = 0

    This makes it so you can only jump when on land. Or at least in theory it should. That way they can't hover in the air indefinitely. Now this would make it so they hit the side of a platform they could jump again. So you may need a "ground" actor then an actor for the sides of the platforms. That way even just hitting sides or even walls won't let them jump.

    Lemme know how this works out for ya. Again it should work with some tweaking, but it's theory only, so who knows.

    EDIT: When I said up in the previous post, I meant whatever you use to make it go up. Just didn't feel like typing it all out =)

    -JGary
  • harrioharrio Member Posts: 234
    what's cookin,

    i like that method jgary321, especially the separating the walls from the ground. i could see using that method to create gameplay where only certain surfaces are 'jumpable' as part of the game...nice job.
  • KamazarKamazar Member Posts: 287
    Awesome, JGary. I'll put that together with one of the rule sets I came up with, and if it works out, I'll post a demo and the code so any of you can try it out and optimize it.
  • KamazarKamazar Member Posts: 287
    So I finally got around to trying out your method, JGary. Weird thing, though. It only seems to work once. My code is practically identical to what you wrote down and what the Basic Platformer template uses. It launches my actor into the air, it comes back down, and then it won't work again. It makes no $$@! sense!!! I've been trying to fix it for the past hour with no avail.
  • harrioharrio Member Posts: 234
    what's cookin,

    hey k, post the rules. fresh eyes do wonders.
  • JGary321JGary321 Member Posts: 1,246
    If I had to guess then I would say that it's not resetting back to 0. Did you make sure to setup the "collides with ground actor reset to 0"?? I would play with that part, b/c thats probably where the problem is. Check & recheck. I am pretty sure it's something with that. Try posting some pics so we can see.

    -JGary
  • KamazarKamazar Member Posts: 287
    Ugh, Safari's being screwy and won't let me log-in. Had to use Firefox, weird. Anyways, here's a screenie. Different scenario here, though. I was working with GameSalad on a different iMac, but had to use the flash image since I couldn't install the app into the applications folder. I'm guessing the file wasn't recognized, and I couldn't email it to myself, so I started the game again from scratch. This time, the object won't jump at all. Even if I get rid of the "if ground = true" and just stick with accelerate toward (I use this behavior to not have to use the timer). I keep getting the feeling that it's something simple that I've overlooked. Anyway, yeah...

    http://img233.yfrog.com/img233/4576/gsjump.png

    Oh, and JGary, I tried that theory out on the original build by changing the boolean attribute to an integer attribute, and setting up a counter display. It alternated from 0 to 1, so it can't be what you said, but I'll try it again with the new build.
Sign In or Register to comment.