AnimationPlayer on random value

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

Hello. I am doing a 2d light glowing animation. I use AnimationPlayer node for this task, by scaling the light texture from 0.5 to 1.0, and back to 0.5. (repeat loop)

However, I would like to make the light glowing more naturally by changing the scaling to a random value, instead of scaling in between a fix value of 0.5 and 1.0.

May I know if AnimationPlayer node is possible to allocate a random value in it’s key frame after every loop of animation?

As the answer suggests, you want to Tween your light and not animate it, as tweening is better for both performance and runtime animation generating, like what you want…

Tweening is generally better for anything that isnt complex(like a up down scaling button) since a Tween node can do multiple animations at once and AnimationPlayer can play only one

rustyStriker | 2020-05-13 19:55

Thanks! Since you mentioned that tweening is better in performance, does it means that it is always better to use tweening instead of AnimationPlayer if the situation allow?

pengyou | 2020-05-14 02:14

:bust_in_silhouette: Reply From: jgodfrey

Instead of an AnimationPlayer, why not do this with a Tween instead? Both are similar for this type of “simple” animation, but the Tween is easier to adjust via code (IMO).

Thanks! I will try it out tonight about Tween in Godot

pengyou | 2020-05-14 02:07