make an input overwrite another one

0 favourites
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • 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 >,<)

  • 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.

  • Keyboard: Down arrow is down
      -> Sprite: Start ignoring Platform user input
    Keyboard: [invert] Down arrow is down
      -> Sprite: Stop ignoring Platform user input
  • 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

  • [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 :

    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

    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 (: )

  • .< 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

  • 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
    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

    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 :D

  • 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 >.<)

  • then change the

    Sprite: is on floor
      ...
      ...
      Keyboard: on down arrow pressed
        -> sprite: set animation to crouch
        -> sprite: set crouching to true

    by

    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
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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?

  • I used a boolean to choose among the two and somehow it works again :)

    don't know if this is the best solution but I don't have any other in mind at the moment :P

    Thank You for your hel again! ;)

  • Yeah it was the aim of the 'trigger once'.

    I didn't wrote it nicely I think you misread that the 'trigger once' was a nested condition

    +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
      +System: trigger once
        -> Sprite: set animation to 'crouch'
  • Mhm.. well to be honest it works good even without the trigger once option O.o

    trigger once should mean that the animation is executed only one time, the first time, so without it I shouldn't have the same effect maybe.. am I missing something? O.o

  • your crouch animation have probably only one frame, so you don't get the "freezing" animation effect by calling it every time

  • mhm.. no? XD

    the actual crouching animation that I'm using (even if not mine) have something like 13 frames, so I just supposed that it would have caused trouble (in fact after an attack I have to play a single frame with the character crouched in order to non repeat the same animation again), but it's not the case.. this is why I think I'm missing something >.<

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