Animating & Jumping

brett-nortonbrett-norton Member, BASIC Posts: 64

Hi Everyone.

Just putting my character together in my platformer. Im struggling to find the best way to achieve the best set of rules to include regular moves walk left/right and jump and incorporate there animations.

Main problem is when in mid jump and facing left i have graphics flipped and have the animation in process but if i move right mid jump the animation starts over and doesnt continue how is this worked around?

Thanks

Comments

  • imjustmikeimjustmike Member Posts: 450

    Difficult without seeing how you've implemented your rules, but in that specific instance you could use a combination of rules so that when facing right (or left), and on the ground, do walk but when facing right (or left) and not on the ground, just flip the image

  • brett-nortonbrett-norton Member, BASIC Posts: 64

    Ok so i have now got it working fine keeping in mind its just a basic bog standard platformer movements that is needed is the following rules ok?

    Or is there a better method my method below seems like a lot or rules.

    [Regular Move Group]

    Move Left - If game.touchleft = True DO self.motion.x to -300 Else self.motion.X to 0

    Move Right - If game.touchright = True DO self.motion.x to 300 Else self.motion.X to 0

    Animate Walk Left - If game.touchleft = True and game.grounded = True DO Animate & self.graphics flip horizontal to True

    Animate Walk Right - If game.touchright = True and game.grounded = True DO Animate & self.graphics flip horizontal to False

    Idle Animations - If game.grounded is true & self.motionx = 0 Do
    Rule Idle Left - If game facing left is true DO Animate
    Rule Idle Right - if game facing right is true Do Animate

    [Jump Group]

    Jump - If game.touchjump = True DO self.motion.Y To 800

    Grounded Check - Colide with floor Do game.grounded To True

    Jump&Fall Animation - IF self.motion.Y is >0 & game.grounded is False DO Animate jump
    Else otherwise - IF self.motion.Y is <0 & game.grounded is False Do Animate Fall

    Jump Graphics Flip - If game.facing.left is true & game.grounded is False DO self.graphics.flip.horizontal To True
    Else Otherwise - If game.facing.Right is true & game.grounded is False DO self.graphics.flip.horizontal To False

    Sorry if its a long read i just want to start off on the right foot if anyone could be kind enough to advise me.

  • IceboxIcebox Member Posts: 1,485
    edited June 2017

    This is one way to do it but i didnt try it.

    Move rule

    if game.touch right is true
    move right
    change attribute self.flipp horizontally to false
    otherwise
    if game.touch left is true
    move left
    change attribute self.flipp horizontally to true
    otherwise
    change selfmotionx to 0

    Animation rule

    if game.grounded is true (if grounded)

    if self.motionlinearvelocityx is 0
    animate idle
    otherwise
    run animation

    Otherwise (if not grounded)
    if self.motion linearvelocity y > 0 animate jump
    otherwise animate fall

    i dont know why you need idle left animation and idle right animation if your going to flip the graphic horizontally but in case you want to do that wrap the animate idle animation in a rule

  • brett-nortonbrett-norton Member, BASIC Posts: 64

    Works a million times better, and now much easier to implement other animations in with them. Awesome thanks.

Sign In or Register to comment.