OK an easy one ! animationtree

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By purple_mage

i have this !

@onready var animation_tree: AnimationTree = $AnimationTree   
 func player_interact() -> void:
	$AnimationTree.set("parameters/conditions/opening", true )

then !

func _on_area_3d_area_exited(area: Area3D) -> void:
if(test != null && test.is_in_group("external_inventory")):
	test.animation_tree.set("parameters/conditions/close", true )
test = null

My chest open . close once then doesnt want to listen !!
my print … print the chest and everything seem to work but im not able to replay the animation once it open and close once !

Why set test null after close, but also testing for null? Perhaps test is null the second time through and thus never sets the animation parameter. Or your tree has conflicting states (opening and close). There’s not enough information here to help.

spaceyjase | 2023-03-29 11:30

the test is null because i set it null when i exit the area3D when checking for collision . Anywayt i think its not the code but the animationtree have an issue somewhere.

the second time the test isnt null , it detect the chest . forget about test it is just to play with object that can be interacted with. I played with the code i think its in the animationtree the problem but i dont know QQ!

its weird ! my animation is a boucle really simple open and close in a statemachine tree root

if you need screen shot or more info tell me !

purple_mage | 2023-03-29 13:19

here a video showing the code and the animationtree !


purple_mage | 2023-03-29 15:44

This should be added as a Comment, not an Answer. You can hide this response and add it back as a comment if you want. Otherwise, people looking at the main board will see that your question already has an answer and may not even look at it.

jgodfrey | 2023-03-29 15:53

ok… if i change the animation closed for opened i can see the animation cycle … i dont understand i switch the animation once … i dont understand why they cycle btw them .
i mean exited area is called once … and the opening is called once too ! why !

purple_mage | 2023-03-29 18:02

I can’t view your video sorry. Once those parameters are set, you need to change them again otherwise the animator will just action the transitions again. For example, if the animator transitions when ‘open’ is true, it will always transition until otherwise.

spaceyjase | 2023-03-29 18:16

hmm my chest has a Idle animation but its like 1 frame… o_o is it the problem ? I dont understand do i have to put “false” at the animation to avoid them to cycle or what

purple_mage | 2023-03-29 18:29

i give up ! its easier with player and monster ! dumb chest !

purple_mage | 2023-03-29 18:38

got it ! … in a function that roll once it doesnt work well. Once i put it in _physic_process it work o_O

var Switch = true   
func _physics_process(delta: float) -> void:
	$AnimationTree.set("parameters/conditions/opening", !Switch)
	$AnimationTree.set("parameters/conditions/idle", Switch)

its not pretty code . Would it be better to use signal o_o

purple_mage | 2023-03-29 18:59