Godot Version
Godot: 4.2.2
Question
Animation Tree
Hello all,
This is a hard question to ask. So I’ll start at the beginning. When I started learning about Godot all the animations used in the tutorials where created using Animated sprites. Was an easy way to do it but you manually had to tell Godot when to switch animations and got very messy very quickly. Then I did a course were the animation were “controlled” by the Animation Tree. The animations were created in the player and the Animations were controlled by the tree. The thing is that the way the animation were controlled in the Tree was not really explained, yes, through trial and error I have been able to add some things that I wanted but there are other things that I want to add and have no idea where to start.
For this project I want to add ladder climbing to the project. I say add, but, the ladder climbing is implemented, it’s just not being controlled by the Animation tree - just to make sure I had a clear idea of where I was going. I made animated sprites and used the manual control to make the sprite states visible and change from “idle” to movement states on the ladder. I also plan to add wall-climbing wall-jumping behaviours later. Saving the hardest part till last.
Now the plan is to add the ladder climbing to the Animation Tree, but, as I said I have no idea how. You can jump to the ladder as well as just climbing just to make it a little more difficult.
Currently I have three animation trees from the “root” for the non-weapon state. I really don’t understand how they work together and wasn’t really explained in the course - I really needed more experience with Godot before jumping into this course. I had the same problem with the animation controller in an Unreal course they were given to us without explaining how it “REALLY” works. So I don’t get where I need to add the ladder climbing, I do have a basic understanding of the switching and the expression used in the Animation Tree, but that is it.
These are in order (see piccies):
Root: following “Without Sword”
-
Without Sword
-
Movement
-
Locomotion
So, I need help as to how to go about adding the ladder climbing and how to handle the jumping to the ladder without coding the sprites manually. For instance I don’t know whether i need to add the state to the existing framework somehow or whether I need to add another branch to the tree. And if I add a new branch to the tree, how, I would hook it up the existing framework to get it all working.
The code currently controlling this part of the project as of today far is this:
if(! is_on_floor() && on_ladder):
#this works
#print("Ladder up!!!");
#turn off jolly roger completely when on ladder
#and turn on ladder_anim
sprite_2d.visible = false; #works
ladder_anim.visible = true; #works
#if (velocity.x != 0):
#print("Stop moving");
#velocity.x=0;
if(Input.is_action_pressed("run_left")):
print("Roger wants to move left");
ladder_anim.play("ladder_climb");
velocity.x = -2;
elif(Input.is_action_pressed("run_right")):
print("Rightio");
ladder_anim.play("ladder_climb");
velocity.x = 4;
else:
velocity.x = 0;
if(Input.is_action_pressed("Up")):
print("Roger wants to move up");
ladder_anim.play("ladder_climb");
velocity.y = -90;
elif(Input.is_action_pressed("Dash")):
print("roger wants to move Down");
ladder_anim.play("ladder_climb");
velocity.y = 90;
else:
stop_jump();
print("Idling on the ladder");
velocity.y = 0;
#stop_jump();
#end inner if
#end if
#-- end ladder code ------------------------------------------------------
I know that was hard slog getting through the question. But I want to be thorough with what I have done and what I need to do. So if you have any advice on how to proceed any assistance would be gratefully accepted.
Warmest Regards.