How to optimize this in godot?

Godot Version

4.2.2

Question

I did some animations in my player with a sword, i put a 3D sword in my player using subviewport, and it works as expected:

the problem is that i want to put more than one sword, like a equipable item, and using this approach i need to put all the swords i have in the node of player, i guess it can be really heavy and not very well optimized, so i wanted to make this dynamically, but the swords could have different shapes and sizes and the animation can be strange. I thought about doing an animation for each sword in a separated scene but it still very difficult to put the swords in the correct places. Someone could help me?

Have you measured the performance impact of loading swords vs swapping visiblity? Do not try to optimize small things without measuring.

I would prefer to load swords as needed, with one animaton for all of them. You could add a AnimationPlayer under the sword, and play it’s animation through an Animation Playback Track; as long as the sub-animation player and it’s animation name are the same for all swords, I do something similar for guns in my game, though they all share a script that plays the animations when appropriate.

1 Like

I’ve tried to do that, but the animation is very delayed, and some animations that i did is not playing correctly

It’s seems like when it plays the animation it stops before it is finished.

1 Like

Huh I think 4.2.2 broke sub-animation tracks, they don’t work right when keyed at 0 seconds. try moving that animation track key to 0.001 seconds?

1 Like

It works, wtf

yipee bug report time!

2 Likes