How to prevent character from walking in midair while jumpin

Just started using Construct 2? Post your questions here

Post » Thu Oct 13, 2016 12:33 pm

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!
B
4
S
1
Posts: 2
Reputation: 304

Post » Thu Oct 13, 2016 1:47 pm

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 #
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
66
S
17
G
8
Posts: 637
Reputation: 9,370

Post » Thu Oct 13, 2016 4:34 pm

chrisinfinger wrote: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! :)
B
4
S
1
Posts: 2
Reputation: 304

Post » Fri Oct 14, 2016 1:15 am

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?
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
66
S
17
G
8
Posts: 637
Reputation: 9,370

Post » Sat Oct 15, 2016 12:12 pm

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.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Sun Oct 16, 2016 12:13 pm

If I understand correctly:

event - right arrow is pressed - move 2.5 pixels forward
subevent -animation jump is not playing - play walk animation
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to Beginner's Questions

Who is online

Users browsing this forum: blackhornet and 1 guest