Attack animation

I have a certain animation so that when the attack button is pressed an actor will have an attack animation. I have it set so that when the characters linear velocity x is less then 0 he animates left and when it is greater then 0 it does the right animation. Unfortunately the code is set so you have to be move left and press the attack button to get the left animation and vice versa. This ends up so that if you aren't moving the character the game cannot choose which animation to use and starts spasming and using both sides and it ends up looking glitchy. Is there any way to fix this?

Comments

  • gamestudentgamestudent Member Posts: 504

    Maybe create two bolean attributes, left and right, and create your rule to say:

    When any
    left is true:
    when self.linear velocity < 0

    animate function

    And then you would have your controls that make your character move left change left to true. and then false in the otherwise box. then the same for right only > and right attribute.

    Hope it works. :smile:

  • GrolarbearGrolarbear Member Posts: 50

    The problem i am having is that when you aren't moving it glitches and i cant figure out how to make it so that when you arent moving it animates right

  • simon31184simon31184 Member Posts: 14

    Create two boolean attributes game.LookingLeft and game.LookingRight and set them when left button is pressed game.LookingLeft is true and game.LookingRight add this rules on your player movements left and right. The same for the right button pression but inverse. So set the animations with: if game.LookingRight is true and your button for the attack is pressed : animation for right. The same for the left.
    Set also the change image behavior for game.LookingRight and self motion x and y 0 to image stand right and the same for the left.

  • ookami007ookami007 Member Posts: 581

    @simon31184 is right... or on the right track. There are many ways to do it. In my game, I have a facing attribute. I set it whenever the direction changes, this way I always know the last direction they were facing.

Sign In or Register to comment.