Godot Version
Godot 4.2.2
Question
In my continuing quest to get the Animation Tree working within the current framework of the project I am working in, is this problem.
What I am getting is this:
Notice that ol’ Captain Roger is facing the screen and is using the “jump” animation, when want I want through the Animation Tree is the “ladder_Idle” animation. As it is currently, if I hit and hold the “up” button on the keyboard the character goes into this incorrect animation. Should I lift my finger off the up arrow it then and only then goes into the correct animation.
Now this is the:
- !is_on_floor() animation – the jump animation which would be correct.
But I have set the Animation Tree to:
- (!is_on_floor() ) && (on_ladder)
So, while the character is on the ladder, but, not in the air then situation normal. Then after the up button is pressed we are in the air now, so, it should to me should play the correct animation, the “ladder_idle” animation NOT the “jump” animation. Which is this:
What I want is this (see piccy below). Now I have the Ladder_animation playing after lifting my finger off. Now it can access the ladder_climb animations for moving up/down the ladder, can move off the side of the ladder and everything works correctly, climb to the bottom of the ladder no prob, and can jump onto the ladder as well.
It’s just the initial “up” button that is causing the snafu. I am having trouble seeing what the cause could be. I have tried a number of different things none worked and I really don’t understand how the animation Tree works, but, I am trying. One thing I did try was making the sprite invisible when the sprite was supposed to change then make it visible again after. That process worked using the animated sprites (still in the code commented out), also to that end using the:
• await get_tree().process_frame;
To do something similar, but, no dice.
Just a moment ago I was wondering if I might be using the wrong type of Input at the beginning of the loop, but, I don’t know. I don’t want the player to have to hit the Input button twice.
This is primarily all the code I am using for the ladder (yes, the code is all over the place, it is a work in progress):
#-- ladder code in: air_physics ------------------------------------------
if(! is_on_floor() && on_ladder):
#this works
#print("Ladder up!!!");
#turn off jolly roger completely when on ladder
#with animated sprites
#and turn on ladder_anim
#taken out for aniTree
#sprite_2d.visible = false; #works
#ladder_anim.visible = true; #works
if(Input.is_action_pressed("run_left")):
print("Roger wants to move left");
#ladder_anim.play("ladder_climb");
#anim_player.play("ladder_climb")
velocity.x = -4;
elif(Input.is_action_pressed("run_right")):
print("Rightio");
#ladder_anim.play("ladder_climb");
#anim_player.play("ladder_climb")
velocity.x = 4;
else:
velocity.x = 0;
if(Input.is_action_pressed("Up")):
velocity.y = -90;
print("Roger wants to move up");
#ladder_anim.play("ladder_climb");
#anim_player.play("ladder_climb")
elif(Input.is_action_pressed("Dash")):
velocity.y = 90;
print("roger wants to move Down");
#ladder_anim.play("ladder_climb");
#anim_player.play("ladder_climb");
else:
#not exactly why this parts works not with anim_player
stop_jump();
#anim_player.play("ladder_idle");
print("Idling on the ladder");
velocity.y = 0;
#end inner if
#end if
#-- end ladder code ------------------------------------------------------
If you require any more information like my convoluted AniTree and switches just ask and I’ll post it.
Any and all help is greatly appreciated.
Thankyou and Regards.