4 Direction and button combination

0 favourites
  • 10 posts
From the Asset Store
Over 2700 files with all the colour combinations from a 15 colours palette!
  • Hello!

    I am using the 8direction (set to 4 directions) for a top-down game. On the keyboard, sometimes one wants to hold a second button to change direction momentarily.

    For example, I go left if I hold the "A" key. If I am still holding that key, and I also press the key "W", the "A" key is as if it's frozen, and now your character goes up.

    If you release the "W" key, and you are still holding the "A" key, you come back moving left.

    Now, with the behavior 8direction (again, set to 4 directions), I can do this combination only if the player has started moving horizontally (left or right).

    If I start moving up or down, holding the key, and pressing left or right, my character won't change direction.

    I also have tried messing up with the events, and I was able to revert the combination, meaning the player can come up with this combination if moving vertically. But now I can't do that for the other 2 horizontal directions which used to work before...?

    I am not sure if it's a bug. I don't think so... But at the same time, it's definitely something that doesn't make sense when using the behavior.

    That is all, thank you for reading!

  • Yeah it was always like this as far as I know but you can use events to make it do the preferred expectation for your game.

  • I would Imagine it will take into account your lowest code -

    If rightArrow: Move Right

    If downArrow: Move Down

    If you press both right and down it will see you are pressing right then in the same instance see you are pressing down and override your move to Down.

    You'll need to create a movement state

    If upArrow and rightArrow :

    Else If rightArrow and downArrow:

    (One for each angle then one for each single button direction, this way they don't ever overlap)

  • I would Imagine it will take into account your lowest code -

    If rightArrow: Move Right

    If downArrow: Move Down

    If you press both right and down it will see you are pressing right then in the same instance see you are pressing down and override your move to Down.

    You'll need to create a movement state

    If upArrow and rightArrow :

    Else If rightArrow and downArrow:

    (One for each angle then one for each single button direction, this way they don't ever overlap)

    Thank you for your answer! Yes, I have tried what you said, but for no reason, the "direction combination" seems to work only in 2 ways and they continue to overlap.

    Meaning, it may be that I did something wrong, although I got what you said, logic-wise.

  • Looks like the way I did it was with

    Up and Not right and Not Left - travel up

    You can check out this video I build a movement system from scratch

    youtube.com/watch

  • Looks like the way I did it was with

    Up and Not right and Not Left - travel up

    You can check out this video I build a movement system from scratch

    https://www.youtube.com/watch?v=kgzUl98u-s4

    Ah yes, I have followed some of your videos. keep it up with the content!

    Unfortunately, I have tried multiple times and ways, in the way you make the events, which I also used the else if needed, but there is always this overlap that doesn't allow me to use all 4 directions for the combinations. Only 2.

  • Do you mind sharing your game code with me.

    You can do it through discord so it is more private if you would like: discord.gg/fjAuxJNE

  • Do you mind sharing your game code with me.

    You can do it through discord so it is more private if you would like: discord.gg/fjAuxJNE

    Thank you for your help! However, I believe I have found the way I needed to add the feature.

    In short, for each button pressed, the button gains a position up to 4.

    (Yes, I have used 4 number variables for this.)

    If I press left, right, and up, the position would be 1st, 2nd, and 3rd respectively.

    Eventually, I might even press the down button and reach the 4th number.

    The highest number gets the highest priority. Meaning, if I release the down button (number 4), it will automatically move up (number 3), and if I release this key, it will automatically move to the right (number 2), and so on.

    To do this, I just made a sort of... tournament flow chart against the variables.

    Something like this:

    UP > DOWN
    	UP > LEFT
    		UP > RIGHT	[UP]
    		
    		UP < RIGHT	[RIGHT]
    	UP < LEFT
    		LEFT > RIGHT	[LEFT]
    
    		LEFT < RIGHT	[RIGHT]
    UP < DOWN
    	DOWN > LEFT
    		DOWN > RIGHT	[DOWN]
    		
    		DOWN < RIGHT	[RIGHT]
    	DOWN < LEFT
    		LEFT > RIGHT	[LEFT]
    
    		LEFT < RIGHT	[RIGHT]
    
    

    Took me 7 hours but here we are! Can't believe I did it on my own...

    Either way, sharing my problem was incredibly important to think of a way and I hope the solution provided might help someone else.

  • I often think of ways to solve my problems when I am writing out my question for the forum. It’s all about a new perspective! :)

    Glad you were able to figure something out!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I often think of ways to solve my problems when I am writing out my question for the forum. It’s all about a new perspective! :)

    Glad you were able to figure something out!

    Couldn't agree more!

    It happened more than once.

    I think exposing the problem by typing, even if you're not going to post it, will make you meditate about the solution.

    Anyway, it's 4 AM here so I guess it's time for me to rest with a good ending.

    See you around!

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