Is it able to let different nodes play the same animation with different keys' value at the same time?

Godot Version

4.2

Question

now,i use a stupid way to let every node has its own animation,so they can play animation with individual parameters.here are my codes below,i just let node create a copy of the same animation,and when they exit scene tree,i remove this copied- animation from animationLibrary.

func registerAnimation():
	animationLibrary = animationPlayer.get_animation_library("TimeLineBlock")

	anim_add = animationPlayerManager.getAnimation("add")

	anim_horizontal_move = animationPlayerManager.getAnimation("horizontal_move").duplicate()
	animationLibrary.add_animation(anim_horizontal_move_name,anim_horizontal_move)
func moveToOrigin(val:float):
	anim_horizontal_move.track_set_key_value(0,0,val*size.x)
	anim_horizontal_move.track_set_key_value(0,1,0.0)

	await animationPlayerManager.playAnimationSyncWithSpeedRatio(anim_horizontal_move_name,0.4)

evidently,this costs many extra unnecessary efforts,is there any more smart ways to fullfill this need?bcs this kind of node is create/exit_scene_tree frequently

Animations usually work based on absolute values. They are set up during design time and generally don’t change during runtime.

If you need dynamic, changing values in animations, then Tweens suit much better for these needs. Especially if you construct your animations in code anyway.

thks,before reading ur comment,i dont know Tween could be used for animation XD

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