Diagonal walking issue

This forum is currently in read-only mode.
From the Asset Store
The Snail Sprite Sheet includes a detailed walking animation for a cute, cartoon-style snail character.
  • Hi all!

    I have searched through google, read the FAQ and browsed various guides but I haven't found a solution.

    I am sure it's something simple.

    My little program is basically making a sprite move with the arrow keys. I'm not using a behaviour for this but just polling keys and changing the X and Y properties of the sprite.

    Depending on what key is pressed I swap out animations so that the sprite is walking.

    This works well but I can't get it to work when you press up and right for example. I want diagonal movements to be like left and right (so if I press up end right I want the right "walking right" animation to play.

    My naming convention for the animation is simple like SL (Standing and looking left) or WU (Walking up).

    Here is my cap file: dropbox.com/s/wpb53dlchye5vh4/Walking%20Animation.cap

  • You just answered your question. If you want to play the "walking right" when you press the up and right buttons, create the event where you set these rules. Something like this:

    + MouseKeyboard: Key Up arrow is down

    + MouseKeyboard: Key Right arrow is down

    + System: OR

    + MouseKeyboard: Key Right arrow is down

    -> Character: Set animation to "WR"

    You should handle the animations in different events than the movements, or this solution will not work correctly of course.

    Note: if you would like to change the controls in the future you will have a lot of trouble, use some pv instead.

    + MouseKeyboard: Key Right arrow is down

    -> Character: Set 'state' to "R"

    + Character: Value 'state' Equal to "R"

    -> Character: Set X to Character.X +1

    This way you only have to change the first event if you want to switch to wasd for example, not the whole sheet.

  • Thanks for the help!

    I removed the movement for now and just trying to get the animations working.

    When I remove the code for going straight up and down the animations work like I want them. But adding the code for going straight up and down breaks the diagonal animations again.

    DropBox file has been updated and here is a screenshot of the code:

    <img src="http://img502.imageshack.us/img502/4770/walkingh.png" border="0" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You are welcome. Put these inverted events in your sheet and it will work correctly.

    <img src="https://dl.dropbox.com/u/2721498/2stroke/Construct/forum%20help/move_anim.png" border="0" />

  • Oh wow thank you for your help!

    Looking at the code I'm actually shocked how many lines it took for this to work right. I actually didn't know about the "Invert Condition" feature, so that was very helpful.

    I have again uploaded the final code: dropbox.com/s/wpb53dlchye5vh4/Walking%20Animation.cap

    And here the code. Maybe someone else will run into this problem :)

    <img src="http://img33.imageshack.us/img33/9159/1to7.png" border="0" />

    <img src="http://img59.imageshack.us/img59/91/8to12.png" border="0" />

  • Hey guys,

    I have the same problem yet no matter how much i looked for, i just couldnt find how to add an "OR" to the conditions. I can make an "OR block" but then it'll place -OR- between every single conditions.

    Thanks for your help already.

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