New Animation Tree Question?

Godot Version

4.2.2

Question

I just have a quick question about the animation Tree I have this code on the expression statement to change the animation:

!is_climbing || no_climb()

which runs this code:

func no_climb():
	if(is_on_floor() ):
		is_climbing				= false;
		is_near_climbing_area	= false;
		print("no climbemo ese");
		return true;
	#end func

Now the code does what I want in that it ceases the climb animation when the character reaches the bottom of the ladder ie, is_on_floor(), however. the variable is_near_climbing area is set to false so I cannot re climb the ladder without moving out of the ladder collision area so the ladder scene can reset it to true. The ladder scene sets this variable. Without setting this variable if you continue to hold the down arrow the character moves into the terrain which I am trying to avoid (why, don’t know) ala this:

Can anyone think of a solution as I am out of ideas completely?

If you can help here is a big thankyou in advance.

Regards.

You can use shape cast instead of area in this case. You must be set the layers/masks properly for a proper game. So if you already done it, then add a shape cast node, set it’s mask so that it will only detect the player and change its max result to 1.

Then you can do like this:

is_near_climbing_area = shape_cast.is_colliding()

After it, you can write that statement.

!is_climbing || no_climb()

It’s just the concept, you will better understand your codes, so just adjust it as you like.

1 Like

Wow, I think that counts as a solution :smile:. I don’t think I’ve ever used the shape cast 2D before, I certainly don’t remember using it. Something definitely new.

Thanks for the information! I’ll try it out and see how it goes :sunglasses:

Cheers.

1 Like