duck-tween
duck-tween copied to clipboard
ScaleX, ScaleY, ScaleZ don't work independently in parallel on the same transform
Problem
If we do the following:
tween = new ParalleledAnimation()
.ScaleX(transform, 0.5f, 2f)
.ScaleY(transform, 2f, 1f);
We expect that x will scale 0.5f up to 2 whilst y will scale down 2f to 1f.
However the X will be ignored. Or rather which ever one is updated last on the frame will be respected.
The reason behind this is the extensions for Scaling individual axes (X,Y,Z) are just helpers around the ScaleAnimation
. The ScaleAnimation
tweens between 2 Vector3
values from
and to
In other words ScaleX(0.5f, 2f)
is essentially just a short hand for:
new ScaleAnimation(
from: new Vector3(0.5f, currentY, currentZ),
to: new Vector3(2f, currentY, currentZ),
The result being that it forces the Y, Z values to remain "locked" to their initial values, whilst tweening X. So if another tween (or indeed any other logic) is trying to manipulate Y, Z, it will fail to do so (unless it's updated after the tween).
Possible Solutions
- Make dedicated animations for ScaleX, ScaleY, ScaleZ
- Implementation change to
ScaleAnimation
. 3 bool flags to control which of the Vector3 components we should overwrite. They would be optional and default to true (to keep the same behaviour) but we set them in the ScaleX, ScaleY, ScaleZ extensions.
I tend to prefer the second, but I'm open to suggestions