Animation Tree Problem – Part 2

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.

So much easier with a Statemachine :wink:, haha jk.

So, I would say what are your jump switches and your jump code. Since it is playing the jump animation it means you are communicating to your AnimationTree that your are jumping, and that is taking first priority. You need a way to make climbing and jumping mutually exclusive.

1 Like

You can actually do that with the animation tree, so, I tried changing the value of the priority but still no dice :pensive:.

It’s probably the way I have set it up. I did try using just the AniPlayer directly to control the changes, as you probably saw in the code, but, it didn’t seem to work either there was a delay before the change took place. And then when I got off the ladder the animations started looping between different animations.

Running out of ideas here, the only thing that worked is using Animated sprites and I am trying to move away from that.

Thanks for reminding me about the priority, totally forgot about that!

Cheers.

Well, if you would like I can look at your jump code as well, where is this ladder code written by the way? In physics process? If your jump code and ladder code are in the same func could you just post the whole func block? It might help me see something that you are missing. If not no worries, will to help if you want to give me some more to work with.

1 Like

I have one idea left! One single solitary idea! A complete redo of the Anitree as I currently have it. I just found another problem I completely overlooked before - when I fall off the ladder it goes into the climb-idle animation! I’m not sure whether it did that before or occurred because of something I changed, argh!

So, I’ll try what I’m thinking of but it’s going to take several days then see what problems are left, then I’ll take whatever help I can get.

Ok, got to stop procrastinating - where goes nothing or something or … stop it, get to work :rofl:.

1 Like

Oh my goodness, just got it working - climbing up and falling off ladder both working now!

So, is exiting the ladder (which was a problem but I could’ve lived with) and so is jumping to the ladder. The AniTree is a unmitigated disaster area of trial and error, not much real knowledge going on there, but, at least it is working.

And the cow jumped over the moon … :cow2: :full_moon:

2 Likes