Changing transition state in Animation Blend Tree plays animation every frame

Godot Version

4.2.2

Question

The animations of a viewmodel I’m using are managed through an AnimationTree, which uses a blend tree. Up until now, I had no issues with the animations, but a few days ago, changing transition state made the animation play every frame the key was pressed.
To be more precise, I want the animation to play while the key is pressed, and then change state when the key is released. For that, I used this inside of func physics_process(delta):

	if Input.is_action_pressed("block"):
		current_viewmodel.SecondaryOn()
	if Input.is_action_just_released("block"):
		current_viewmodel.SecondaryOff()
func SecondaryOn():
	AnimTree.set("parameters/Transition/transition_request", "Block")
func SecondaryOff():
		AnimTree.set("parameters/Transition/transition_request", "Unblock")

Using this and the allow_transition_to_self property of the Transition node set to false, when holding the key, the animation just keeps starting in place, and creates this blurry effect because the animation is being started every frame.

Any help would be appreciated.

Alright problem solved, it had nothing to do with the code I provided at the end, it was just another line of code that changed transition state to “Idle” animation if the movement keys weren’t pressed

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.