Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | LotusOrb |
I am using GameEndeavors statemachine.
In my block state I have two animations, one for when I am moving and when I am standing still. I got the standing still animation working correctly and trasitioning into the moving block animation but the problem is when playing the moving block animation, the player continues to show the moving block animation even after I come to a stand still, I want it to switch back to the idle block animation
Heres a look at some of the code.
The transition code.
states.block:
if Input.is_action_pressed("block") && parent.move_input_speed != 0:
return states.block
elif !Input.is_action_pressed("block") && parent.is_on_floor():
parent.anim_player.play("BlockEnd")
#if parent.is_on_floor():
if parent.velocity.x == 0:
return states.idle
else:
return states.run
elif !parent.is_on_floor():
if parent.velocity.y < 0:
return states.jump
else:
return states.fall
In the enter state I call a function called block()
func block():
if is_on_floor():
if move_input_speed == 0:
anim_player.play("Block")
else:
anim_player.play("BlockRun")
#Reduce move speed by half when blocking
move_speed = (speed/2) * Globals.UNIT_SIZE
What I want to happen is when I let go of the left or right key(move_input_speed == 0)
, I want it to stop playing the block run anim and switch to regular block anim
Sorry if this was confusing and hard to follow, thanks for your help.