0 Favourites

How do I make a character turn around with animation

  • This one seems quite a simple one to resolve but I have spent hours trying to make it work and failed, so maybe some of you can help.

    The main player in this game can move left to right (using the mirror), jump and all that.

    While on the ground I want the character to turn around before start moving in the opposite direction so what I did was using "on pressed Right, play the turn animation" then on another Event, I did "once the Turn animation is over, do mirror". This works if I keep pushing in the same direction so the guy turns and starts running, but if I just tap the key to the right, he will do the turn animation, then do the first frame of the turn animation before mirroring, can you tell me how do I solve this?

    Also I have noticed a strange behavior with a few things every now and then, but the most recent example is actually with the turning: If I am moving Left, then release, and press right immediately, the character does not turn as if there was some kind of lag that did not make him register I pressed down the key, but if I do not use the turn (so the character just flips immediately) this is not an issue. It almost feels as if press down key "left" is not working because I am doing it at the same time as "release key right" but I do not think it's that.

    Cheers

  • Could you upload your .capx here. Recreating what you want then trying to fix it will prove difficult without your work to work on.

  • I do not feel too confident sharing assets online, so can someone just tell me how can this be done without messing up the mirrored stuff or the idle/run animations?

    I have done it in several ways, but none of them really worked, when playing with a keyboard is so easy to press left/right and break the system by making it do something like moonwalking and things which would not be possible if using a joystick.

    Ideally I am trying to create something that I remember Symphony of the Night to have.

    You move right, then press left, your character does not stop but rotates in that direction then starts playing the run animation in the opposite direction. And if you press left and right quickly, the character will always stop playing first what's currently playing (without messing up the mirror).

  • It's actually not that hard to implement..

    Something like:

    on pressed left

    -- player is facing right

    play turning animation

    -- player is facing left

    player simulate pressing left

    on turning animation finished

    --player is facing right

    player set facing to left

    -- else

    player set facing to right

    should be a good start..

    I like using this for registering keyboard input:

  • It's actually not that hard to implement..

    Something like:

    on pressed left

    -- player is facing right

    > play turning animation

    -- player is facing left

    > player simulate pressing left

    on turning animation finished

    --player is facing right

    > player set facing to left

    -- else

    > player set facing to right

    should be a good start..

    I like using this for registering keyboard input:

    Thanks I will try this once I get home, so let me get this right:

    Event:

    On key pressed right

    If not mirrorred > Set Animation Turn

    Sub Event:

    If Mirrored > Player simulates press Right

    Event:

    On Turning Animation Finished

    If not mirrorred > Player Is mirrored

    ELSE

    ????

    Did I get the whole thing right? (except the last part I am not sure how to turn that into event since ELSE usually needs first a condition to trigger an action.

  • I'd rather not use the is mirrored and set an instance variable for the direction the player is facing, but yeah, that sounds about right..

    The if not mirrored should be a sub-event so the else event would only react to the "if not mirrored" condition.

    Else doesn't need another condition attached, just right click and select add "else"

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I'd rather not use the is mirrored and set an instance variable for the direction the player is facing, but yeah, that sounds about right..

    The if not mirrored should be a sub-event so the else event would only react to the "if not mirrored" condition.

    Else doesn't need another condition attached, just right click and select add "else"

    I thought you could only do the flipped animation with mirror, are you saying there is another way of setting mirrored? (which is the only way I know how to tell if a sprite is facing left or right).

  • > I'd rather not use the is mirrored and set an instance variable for the direction the player is facing, but yeah, that sounds about right..

    >

    > The if not mirrored should be a sub-event so the else event would only react to the "if not mirrored" condition.

    > Else doesn't need another condition attached, just right click and select add "else"

    >

    I thought you could only do the flipped animation with mirror, are you saying there is another way of setting mirrored? (which is the only way I know how to tell if a sprite is facing left or right).

    Flipping the animation is done with "set mirrored"

    That doesn't mean you can't have instance variables deciding over if the animation should be "set mirrored"

    I prefer using instance variables for this for it makes my events much easier to read..

    player.facing = "Left" VS. player is mirrored

    It's a personal thing, I guess..

  • >

    > > I'd rather not use the is mirrored and set an instance variable for the direction the player is facing, but yeah, that sounds about right..

    > >

    > > The if not mirrored should be a sub-event so the else event would only react to the "if not mirrored" condition.

    > > Else doesn't need another condition attached, just right click and select add "else"

    > >

    >

    > I thought you could only do the flipped animation with mirror, are you saying there is another way of setting mirrored? (which is the only way I know how to tell if a sprite is facing left or right).

    >

    Flipping the animation is done with "set mirrored"

    That doesn't mean you can't have instance variables deciding over if the animation should be "set mirrored"

    I prefer using instance variables for this for it makes my events much easier to read..

    player.facing = "Left" VS. player is mirrored

    It's a personal thing, I guess..

    Ah fair enough, I though there was another way to detected the facing of the character.

    I am guessing you would set the variable "facing right" true when you mirror and false when you do not set mirror, so you can reference this true or false elsewhere. But is there a real advantage in creating an extra thing on top?

  • Ah fair enough, I though there was another way to detected the facing of the character.

    I am guessing you would set the variable "facing right" true when you mirror and false when you do not set mirror, so you can reference this true or false elsewhere. But is there a real advantage in creating an extra thing on top?

    I would use a text-variable and do it the other way around..

    If facing is "left" set mirrored

    There is no use for it other than to make things more easy to read and to help me as a programmer not having to think about mirrored/not mirrored and positive and negative values..

  • Nope it's not working, if I follow the exact same steps written here, literally nothing happens.

    I have tried to tweak them a little but what happens is that it flips the last frame of the Turning animation before going to idle.

    Update: I have done it in a slightly different way by making sure the the Turn animation sprites were flipped backward, then on key press setting the "mirrored" first then tell it to play the turning animation, that worked.

    The problem remains, when I I hold Right+Left, and release either, it starts moonwalking. I do not want that, but I do want it to keep the fluidity of movement when I switch from left to right on the fly (rather than having to stop then turn).

  • The problem remains, when I I hold Right+Left, and release either, it starts moonwalking. I do not want that, but I do want it to keep the fluidity of movement when I switch from left to right on the fly (rather than having to stop then turn).

    That's why I started using the keyboard setup I linked, for this can be easily avoided..

  • >

    > The problem remains, when I I hold Right+Left, and release either, it starts moonwalking. I do not want that, but I do want it to keep the fluidity of movement when I switch from left to right on the fly (rather than having to stop then turn).

    >

    That's why I started using the keyboard setup I linked, for this can be easily avoided..

    Yes but then I get the problem that if the character is running left and I press right quickly while releasing left, it stops dead still and I have to click right again to make it move, making it feel very clunky and sluggish.

  • >

    > >

    > > The problem remains, when I I hold Right+Left, and release either, it starts moonwalking. I do not want that, but I do want it to keep the fluidity of movement when I switch from left to right on the fly (rather than having to stop then turn).

    > >

    >

    > That's why I started using the keyboard setup I linked, for this can be easily avoided..

    >

    Yes but then I get the problem that if the character is running left and I press right quickly while releasing left, it stops dead still and I have to couch right again to make it move, making it feel very clunky and sluggish.

    I'm not sure how you have set things up, so I wouldn't know..

    I never had the problem you described..

    Maybe you are trying to do something very different from what I was assuming or I just don't understand the way you have your events set up..

  • I'd rather not use the is mirrored and set an instance variable for the direction the player is facing, but yeah, that sounds about right..

    The if not mirrored should be a sub-event so the else event would only react to the "if not mirrored" condition.

    Else doesn't need another condition attached, just right click and select add "else"

    to be honest I really don't know I never even thought about that good question.

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