How to prevent character from walking in midair while jumpin

0 favourites
  • 6 posts
From the Asset Store
2d mushroom sprite 2d game mushroom character enmy sprite game art
  • Hello! It's an assignment work and I'm not allowed to use the "Platform" behaviour in this game. I have added keyboard controls to my character as follows:

    Right arrow = Move 2.5 pixels forward and Set animation "Walk".

    Up arrow = Apple Physic force (0,325) and set animation "Jump".

    The problem: When I press "Up", the character jumps and while in mid air if i press "Right", it WALKS forward in midair. I want the character to only MOVE FORWARD(without the walk animation) while jumping when "Right" key is pressed. In other words, how do I prevent the Walk animation while the Jump animation is playing while at the same time allowing the "Forward movement"? My apologies if i'm not explaining this clearly enough

    P.S - someone please reply ASAP, thank you!

  • Put a image point at his feet (or slightly below) and condition out imagePoint1 isoverlapping whateverground/platform in walk event. You can also use isnotoverlapping (right click and select invert on event) in jump event.

    Using GroundSprite overlapping PlayerSprite.ImagePointX(1), PlayerSprite.ImagePointY(1)

    where (1) is imagepoint #

  • Put a image point at his feet (or slightly below) and condition out imagePoint1 isoverlapping whateverground/platform in walk event. You can also use isnotoverlapping (right click and select invert on event) in jump event.

    Using GroundSprite overlapping PlayerSprite.ImagePointX(1), PlayerSprite.ImagePointY(1)

    where (1) is imagepoint #

    Hi Chris! Thanks a lot for your input. Sorry I didn't quite get the grasp of that, I'm pretty much getting started with this. I know I'm asking a lot here, but could you PLEASE try to fix it for me? Here is the capx : www(dot)mediafire(dot)com/file/edrm42t4zel7r1k/Saviour_1.1.capx

    If you indeed do have some time for me, please just send me a screenshot of the code you changed/added (that would be easier for you I guess).

    Thanks a lot anyway!

  • I misunderstood your question obviously.. I reread your problem multiple times and I still am not sure exactly what you're after. I created a .capx using your exact wording the best I could understand and it didn't work as I think you are wanting. The force was applied to jump but if right arrow was pressed the sprite never fell back down it just went right till you released arrow key. Why not use apply force at angle instead?

  • This may take more than a few events to get this affect. Can you try...

    Player > is overlapping object - (add floor object)

    (Add condition(s) to test if there are any more objects the player can walk on- if not, do not add the condition) - 'action' > play "walk animation"

    Keyboard > on key pressed (jump) - player > play "jump animation"

    If that does not work, you could trying adding groups...

    Group > controls

    Add your movement actions here...i.e - move player logic --- Move 2.5 pixels forward and Set animation "Walk".

    Apple Physic force (0,325) and set animation "Jump".

    Sub-group > walk animation (only add - on right key pressed > play "walk animation" events/actions

    Sub-group > jump animation (only add - on key pressed > play "jump animation" events/actions

    Then, still in that 'controls group' but under the sub-groups add...

    On key pressed > jump

    Condition > player overlapping floor object (invert) disable sub-group > walk animation

    I may try and test this later, once i get back to my laptop.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If I understand correctly:

    event - right arrow is pressed - move 2.5 pixels forward

    subevent -animation jump is not playing - play walk animation

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)