make an input overwrite another one

Get help using Construct 2

Post » Sun Jan 08, 2012 11:32 pm

I mean, I'm using the platform behavior and what I'm trying to accomplish is to stopping my character from moving forward (or backward) when I press the down arrow on my keyboard (even if I'm still pressing the right arrow or the left one) and as long as I've the down arrow pressed he should be stopped from moving into other directions.

I'm new to this editor and what I'm looking for (but I still can't figure where it is) is a command to simply stop the directional movements (and only the directional movements).. or a best way to go on :P

have you ever had this problem? (damn crouch function >,<)
B
5
G
1
Posts: 32
Reputation: 939

Post » Sun Jan 08, 2012 11:56 pm

It can be a good idea to turn off the default controls in the behaviour, and to do input commands with events. For behaviours, I think there are actions that "simulate" input commands, so you could have an event with the condition "Left button is down" and then have an additional negated condition which is "down button is not down" (so you don't move while crouching), then have the action say "simulate control left".

Or maybe another way you could try would be to, while crouching, have an action that sets the sprite's platform vextor X to 0.
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Post » Mon Jan 09, 2012 12:01 am

[code]Keyboard: Down arrow is down
-> Sprite: Start ignoring Platform user input
Keyboard: [invert] Down arrow is down
-> Sprite: Stop ignoring Platform user input[/code]
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Jan 09, 2012 2:28 am

@Alspal

I thought of using the simulate control in the beginning but the only chose I have in the scroll men are: Left, Right, Jump (and I haven't understood a way to add more choises yet) I'm using Construct 2 and I never used Construct 1 so I don't know what is different. >.<

If I set vector X to 0 the character won't stop


@Yann
[invert] Down arrow is down
on Down arrow released is the idea?
I tried and it works but partially because the character won't stop immediatly (but it stops)
...but..
if I keep pressed the left(or right) arrow and (while keeping it pressed) press the down arrow and quickly release it (the down arrow), the effect is that the animation goes and the character as well since it keeps moving with the wrong animation instead of being still >.<

I had the same effect with

Keyboard: Down arrow is down
Keyboard: Right arrow is down
+ Sprite: Simulate Platform pressing Left
(the idea was that the opposite direction would have stopped the movement since before posting I tried both vector x, max speed, accelleration and ignoring user imput but nothing seems work well untill now >.<)


P.S. However..
the best result is mixing both your answers xD

Keyboard: Down arrow is down
-> Sprite: Start ignoring Platform user input
-> Sprite: Set Platform vector x to 0
Keyboard: On Down arrow released
-> Sprite: Stop ignoring Platform user input

In this way someway it works ;P
Thanks for the suggestion ;)

by the way, there is a way to put a "or" in a condition? O.o
B
5
G
1
Posts: 32
Reputation: 939

Post » Mon Jan 09, 2012 3:45 am

[invert] means that you right click on your condition and you invert it
It's not the same as "on release".
On release is a trigger, it is true the moment you release the button.
But well... In that case it should work th same (:

And yeah, I didn't know that the deceleration was an issue, nullifying vectorX is the way to go (:

The or is not yet natively implemented but there's a plugin for that.

you can also do something like :
[code]System: Every tick
Local variable or=0
Condition1
    -> System: set or to 1
Condition2
    -> System: set or to 1
System: or = 1
    -> Do the action[/code]
Using local variable is interesting 'cause it's autmatically reseted each tick. And it won't appear in the list of global variable in the rest of the event sheet ('cause it's local (: )

B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Jan 10, 2012 3:10 am

>.< I even used it but I didn't thought to it when I saw [invert] on your reply >.<
I must be really tired :P

what plug-in? O.o

that solution of OR is really good actually however ;)

do you know if there is a way to create other event sheets or a way to simulate something else aside from "jump, left, right" ?
I need "down" >.<
I mean, after landing from a jump, if both the down arrow and the right (or left) one are pressed, he messed up the animation and beside I need to read only the down arrow if both are pressed simultaneously.
so basically a way to exclude a command.. "simulate down" would be perfect but is not present among my choices and I don't know if it's possible to extend them
B
5
G
1
Posts: 32
Reputation: 939

Post » Tue Jan 10, 2012 5:28 am

You can only simulate what is handled natively by the behavior. For platform behavior it's jump, move left and move right only.
If I understand your problem, you want to do something when arrow is down. (crouch?)
so basically it would be something like:
Sprite has two instance variable:
- 'landing' boolean default false //true when landing animation is playing
- 'crouching' boolean default false // true when crouching animation is playing
[code]Sprite: Platform is on Floor
// WHILE on floor doing nothing
Sprite: [invert] Platform is moving
Sprite: [invert] is landing
Sprite: [invert] is crouching
System: trigger once
     -> Sprite: set animation to 'idle'

// WHEN you start moving
Sprite: on move
    -> Sprite: set animation to 'walk'

// WHEN you press down arrow
Keyboard: on Down Arrow key pressed
    -> Sprite: set animation to 'crouch'
    -> Sprite: set crouching to true




//WHILE down is down (you are crouching so you don't move)
Keyboard: Down Arrow key is down
-> Sprite: set Platform verctor X to 0
-> Sprite: set Platform verctor Y to 0

//WHILE down is not down
Keyboard: [invert] Down Arrow key is down
-> Sprite: set crouching to false

//WHEN you start jumping
System: on Jump
-> Sprite: set animation to 'jump'

//WHEN you start falling
Sprite: on Fall
-> Sprite: set animation to 'fall'

//WHEN you start landing
Sprite: on Landed
-> Sprite: set animation to 'land'
-> Sprite: set landing to true

//WHEN you finished landing
Sprite: on animation 'land' finished
-> Sprite: set landing to false[/code]

not that these WHILE and WHEN are very important. Either the condition is true during a period (WHILE) either the condition is true just in an instant (WHEN)
For animation it's important to know if it's a instantaneous or if it lasts, because if a condition lasts you might call an animation every tick, thus only playing the first frame.
That's why, in the first condition, I added the "trigger once"

Well. I say that, but I didn't work with character animation for a long time, so there might be some mistakes.
Also, I might not have answered your question since I got carried away :DYann2012-01-10 05:32:38
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Jan 10, 2012 12:24 pm

I already thought something similar, but the problem is that if the user start pressing the down arrow and the right (or left) one together while the character is still fluctuating (I mean he is in the air and it's either jumping or falling), when the character reach the ground (and the two directions, down and right(or left) are still pressed) he continues moving to right or left.
I'd like to give the priority on the down arrow stopping completely his movement (a plus it would be being able to choose to stop movements for 0.3 seconds ;P)

your solution is similar to mine (so it doesn't work xD)
and setting vector x and vector y to 0 doesn't fix the problem since the effect is that the character keeps moving (even if a little more slowly than before >.<)
B
5
G
1
Posts: 32
Reputation: 939

Post » Tue Jan 10, 2012 2:41 pm

then change the
[code]Sprite: is on floor
...
...
Keyboard: on down arrow pressed
    -> sprite: set animation to crouch
    -> sprite: set crouching to true[/code]
by
[code]Sprite: is on floor
...
...
Keyboard: down arrow is down
    -> Sprite: set crouching to true
    -> Sprite: set Platform vectorX to 0
    -> Sprite: set Platform vectorY to 0
    -> Sprite: Platform start ignoring control
    trigger once
      -> Sprite: set animation to 'crouch'

Keyboard: [invert] down arrow is down
-> Sprite set crouching to false
-> Sprite: Platform stop ignoring control[/code]
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Jan 10, 2012 8:18 pm

YES!! It Works!!
Thank You! ;)

But I used

-> Sprite: stop ignoring platform user input

instead of

"start ignoring control trigger once"

because it's something that I couldn't find >,<
where is it? O.o
But.. well. somehow it works.. u,


however..

putting

Keyboard: down arrow is down
--> Sprite: set animation "crouch"

instead of

Keyboard: on down arrow pressed
--> Sprite: set animation "crouch"

messed up the condition

Keyboard: down arrow is down
Keyboard: on A pressed
--> Sprite: set animation "crouchAttack"

something like the two animations are played at the same time, so
if you press A simply it would make the program play again the "crouch" animation instead of the attack one >.<
am I thinking right?
B
5
G
1
Posts: 32
Reputation: 939

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Magistross, mallorcaredes, zatyka and 24 guests