How do I disable controls input while jumping?

Get help using Construct 2

Post » Sat Jan 31, 2015 8:00 am

Hi, I want to create a platformer game. At first, I used Platformer behavior but I found that when character is jumping, I can freely change its direction mid-air, or if i release arrow key during jump, character stops moving sideways and drops straight down, which is very unrealistic.

I want to disable control input during mid-air and also keep the momentum until it lands.(something like prince of persia, another world, etc.)

I tried "start/stop ignoring input" actions, wasn't successful.
please help me, thank you!!
B
4
S
2
Posts: 7
Reputation: 574

Post » Sat Jan 31, 2015 10:02 am

Add another condition to the mirror event like this :
Player is not jumping (Player is jumping then invert it)

This will prevent the player from moving right and left while jumping.
Image
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Sat Jan 31, 2015 2:23 pm

@A0Nasser, No it won't. Mirroring the sprite does not remove the Platform Behavior's inbuilt ability to change direction in mid-air.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Sat Jan 31, 2015 3:00 pm

@moonsunglee So, what I did was make the input controls manual (toggling off default controls,) and then putting all of the manual controls under a condition, which is set on jumping. Take a look.
You do not have the required permissions to view the files attached to this post.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Sat Jan 31, 2015 3:38 pm

you can use a variable that acts as switch. Then add that variable as conditions for movement, so you can only use the right or left when the variable is a specific value. reset the variable's value when jumping/moving. For this, boolean-type variable can be good enough.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Sat Jan 31, 2015 6:59 pm

@Unnatural20
It's work perfectly
You do not have the required permissions to view the files attached to this post.
Image
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Sat Jan 31, 2015 7:31 pm

@sgn15 I don't agree that a boolean variable is enough. With the built-in platform controls, you lose inertia as soon as you stop holding down the left or right inputs. A variable to maintain inertia and direction is necessary to model the behavior moonsunglee wants.

@A0Nasser As modelled in Prince of Persia, the question is not whether the direction the player is facing changes in midair, but whether you can control the direction of movement. Once the player has jumped in a given direction, he should keep moving in that direction until he lands or falls. Look at my .capx to see, at least, an approximation of the correct motion.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Sun Feb 01, 2015 7:16 am

thank you @Unnatural20! , your example worked perfectly! current speed affecting jump length is beautifully done.

thank you @A0Nasser and @sgn15 also.
B
4
S
2
Posts: 7
Reputation: 574


Return to How do I....?

Who is online

Users browsing this forum: MaujDeveloper, mrkaio, user5487, Zav and 2 guests