Jump & Fall Sprite Change

Hello Blender Buddies!

I’m trying to learn sprite animation in BGE and I was thinking if is it possible to change sprite image during the fall animation? Wherein the object has an image sprite of jumping through the air then the sprite suddenly changes during the fall.

Like so,


Thanks a bunch!

You just need to know that the Z speed is negative, as I assume you’ll want the falling animation to activate when walking off the edge of something during walking as well as out of a jump. Of course, you may want to restrict it somewhat with a property to know if the animation should be modified somehow (shooting and falling, falling against a wall in the case of Megaman).

import bge

cont = bge.logic.getCurrentController()
megaman = cont.owner

#Use these lines if the object to animate isn't the physics object
#scene = bge.logic.getCurrentScene()
#megamanSprite = scene.objects['MegamanSprite']

if megaman.linearVelocity[2] < 0 and megaman['onlyfalling']: #onlyfalling refers to the property
    animationChangingFunctionOfYourChoosing() # You could write a function to pass megaman or megaman.Sprite to, or just write the animation code right here.

I don’t know exactly what you’re using within Blender to animate the sprites so I’d leave that up to you. Just load the above as a Python script with an Always actuator with True pulse and you should be good to go (although I’m sure there’s a more efficient way to set it up).

UPDATE: In addition, some motion actuators can add negative velocity even when you’ve landed and you probably don’t want the appearance of falling if you’re merely walking along an uneven surface. In that case you’d want to tweak the value somewhat (-0.1, maybe even -0.01).

I’ll try to play with the script you gave me. Thank you so much!

your going to want to make a locomotion, action and animation controller,
falling and jumping and ladder climbing are all outside the primary animation state,

I have a controller object take keypresses and convert them to a list,
and send the list to the actor,

this way

if own[‘Move’]==[‘W’]:

is a discreet state

having it inside

if feetOnGround and notJumping and notOnLadder:

makes things pretty easy to manage.