Diagonal Animations don't play in 8-way motion

0 favourites
  • 11 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hello,

    I am trying to create a top down movement similar to RPG Maker type movement except with diagonal movement as well. Currently I have the movement part done and all animations working just fine except those with diagonal motion.

    I have a setup where I use custom controls to allow the player to either use WASD or arrow keys. I separated the events for movement away from the animation ones. But despite that the animations don't play when diagonal movement occurs (for example if I press W and D for example).

    I tried something else by making a variable on the player itself called "animation" and change it whenever a movement key is pressed. However it does't work on all animations. It works on diagonals and left and right but it doesn't work on Up, Down and Idle animations for some reason.

    Here is the .capx file:

    https: //drive.google.com/open?id=0B55-vryvL77VTnJSZ3FXcGJpRDA

    Sorry to break the link but the forums edits it out

    Am I missing something here? Anyone knows how to resolve this issue?

    Thank you for your help in advance.

  • The link is wrong..

    Says I need permission from the owner to get to the file..

    I always use this for movement and animation:

    Easy keyboard setup capx

  • https ://www.dropbox.com/s/45fo473r59sqpcs/Game.capx?dl=0

    Hate Google Drive in these things. Here is the link again, sorry. I have checked your .capx and I think I have a similar setup only the difference is a private variable instead of a global one and handles only animation.

  • If you name the animations correctly it works..

    For example there is no animation called "Down", it's called "Front"

    Also Construct2 read events top to bottom, so if you want to use the "right" and animation for up-right and "down-right" you should put those events at the bottom or add conditions to the above event..

    Setting the animation to play from current frame might be needed if you choose the first option..

    The big difference between my example and what you do is I don't use "key is down", but "on key pressed" just adding and subtracting, so the diagonals are immediatly considered and that's why I don't need to add as many conditions..

  • Well this is really embarrassing now. I didn't notice I gave different names... I need to start making conventions for myself.

    That said, I realize what your example does and now I am using it. Thank you very much. My only problem however is that there is no diagonal movement now. I can only have the character moving in the main 4 directions. I tried adding a condition "On key Pressed W" and "On Key Down D" (as it seems construct doesn't like 2x "On key pressed" conditions) to simulate up + left movement with the variable adding 7, it didn't work.

    Any idea how to make it work with your method?

  • Changing it to or blocks should work,

    on up pressed

    'or'

    on W pressed

    Problem is that than it would be possible to press both at the same time which would add the number twice..

    So probably creating a new event "on W pressed" with an extra condition "keyboard 'up' is not down" and adding W is not down to the on 'up' pressed would be nescessary..

  • That is what I have right now. All the blocks have "On Key Pressed W" or "On Key Pressed Up" simulate control Up (I have 8 way control on the player). But diagonal doesn't work. I made sure that 8-directional is enabled in the behavior too.

    As for the addition and subtraction I slightly edited that. Instead of using "Add" and "Subtract". I just use "Set" so I don't have to worry about the player pressing both button options at the same time.

    Here is how it looks now:

    This setup doesn't allow diagonal movement. If I tried to add a new block with a new number, it still doesn't work. I am guessing to allow diagonal movement I need either to use the default controls + unchanged 8-way behavior or mouse + WASD controls, right?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That is what I have right now. All the blocks have "On Key Pressed W" or "On Key Pressed Up" simulate control Up (I have 8 way control on the player). But diagonal doesn't work. I made sure that 8-directional is enabled in the behavior too.

    As for the addition and subtraction I slightly edited that. Instead of using "Add" and "Subtract". I just use "Set" so I don't have to worry about the player pressing both button options at the same time.

    Here is how it looks now:

    This setup doesn't allow diagonal movement. If I tried to add a new block with a new number, it still doesn't work. I am guessing to allow diagonal movement I need either to use the default controls + unchanged 8-way behavior or mouse + WASD controls, right?

    Well if you change something, some things change..

    I had very specific reasons for using the adding and subtracting..

    Not using it the way I set it up makes the setup unusable..

    You'd just need events that don't contradict..

    if you have an event

    up is down

    and an event

    right is down

    and an event

    up is down 'and right' is down

    all three events are true when both up and right are down..

    So you'd need extra conditions to prevent them all from being true at the same time..

    The example I made was made to simplify that process..

  • Well if you change something, some things change..

    I had very specific reasons for using the adding and subtracting..

    Not using it the way I set it up makes the setup unusable..

    You'd just need events that don't contradict..

    if you have an event

    up is down

    and an event

    right is down

    and an event

    up is down 'and right' is down

    all three events are true when both up and right are down..

    So you'd need extra conditions to prevent them all from being true at the same time..

    The example I made was made to simplify that process..

    Indeed, but if I use the the addition and subtraction with the "Or" condition check, I'll run into the problem you mentioned before. Otherwise I have to do them each on separate conditions like below:

    Key Pressed W and NOT Key Pressed Up, add.

    Key Pressed Up and NOT Key Pressed W, add.

    This would take many events. So I thought the "Set" would work better in this case. I am guessing I'll just end up using the mouse and keyboard for it. Unless there is something I am missing that can be done to allow diagonal motion.

  • Actually it would be way better to have the player choose which of the two he/she wants to use, or even to choose his/her own keys..

    Then using keyboardkeycodes you wouldn't have the above issue anymore..

  • Well that is some magic there. I tried the keycode events and it worked like charm. Thank you so very much for your continued help! Seriously.

    But I have to say I am really confused. Why would the game work with "On Keyboard Code Pressed" with diagonals just perfect but it won't with "On Key Pressed". In my mind they are essentially the same thing except I am referring to a code rather than a specific name... weird!

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