First try feedback (v1.0.9) #6
-
Hi! First of all I want to thank you for your work! PrimeTween has every chance of becoming a top. So here is my list:
I use often all of this methods. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 11 replies
-
Huge thanks for the feedback! I'm glad you enjoy using PrimeTween!
I already know how to add this feature seamlessly to PrimeTween, and will add it in the next version. public static Tween PositionWithSpeed([NotNull] Transform target, Vector3 endValue, float speed, Ease ease = Ease.Default) {
Assert.IsTrue(speed > 0);
var duration = Vector3.Distance(target.position, endValue) / speed;
return Tween.Position(target, endValue, duration, ease);
}
While adding this is totally possible, I don't currently understand the use cases. I would very much appreciate a real-world example that can help me to understand the use cases better.
This is already possible with PrimeTween but in a slightly different way. Let's suppose we have the following code that uses DOTween: transform.DOMoveX(endValue, duration)
.SetDelay(delay)
.OnStart(() => print("Delay done"))
.OnUpdate(() => {
OnPositionUpdated(); // delegate allocation! 'this' reference is captured inside a closure
}); The above code can be implemented with PrimeTween in the following way. Although it looks less pretty, it prevents delegate allocation. I will add the OnUpdate() equivalent in the future for more convenience. Tween.Delay(delay, () => print("Delay done"))
.Chain(Tween.Custom(this, transform.position, endValue, duration, (_this, val) => {
_this.transform.position = val;
_this.OnPositionUpdated(); // no allocation
}));
I didn't want to pollute users' projects with additional files, so all settings in PrimeTween are located inside the PrimeTweenConfig class. You can choose the default ease with the help of LoopType is called CycleMode in PrimeTween and I believe it shouldn't be a global setting for the whole project. Every animation is different, and explicitly setting a CycleMode for every animation is a more readable and reliable approach in my opinion. As for the autokill, PrimeTween doesn't have such a concept by design. Animations in PrimeTween are non-reusable; that is, you can manipulate the tween only while it 'isAlive'. But once the tween finishes (or you call Stop() or Complete() manually), it becomes 'dead' automatically. This prevents common performance pitfalls and makes the code much more simpler and reliable.
Yes, I have the path animation on my roadmap and I will add it in future versions. Although, as you mentioned, this feature can have a lot of caveats, so I don't want to hurry with it.
I should also mention that the migration is optional and you should do it with care in the existing projects. PrimeTween doesn't conflict with DOTween, so you can migrate only those parts that are critical for the performance. |
Beta Was this translation helpful? Give feedback.
-
How to replace the |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@EnterUserNamePlease I added the OnUpdate() callback in version 1.0.12. Usage example: // Rotate the transform around y-axis as animation progresses
Tween.PositionY(transform, endValue, duration)
.OnUpdate(target: transform, (target, tween) => target.rotation = Quaternion.Euler(0, tween.interpolationFactor * 90f, 0));
// Call the OnPositionUpdated() method on every position change
Tween.PositionY(transform, endValue, duration)
.OnUpdate(target: this, (target, tween) => target.OnPositionUpdated(tween.progress)); |
Beta Was this translation helpful? Give feedback.
-
@EnterUserNamePlease I added FixedUpdate() in version 1.1.4. Here is the documentation for the feature: https://github.com/KyryloKuzyk/PrimeTween#fixedupdate |
Beta Was this translation helpful? Give feedback.
-
As you've correctly pointed out, path (spline) is a quite complex domain, that hard to implement correctly. After long consideration, my current conclusion is that PrimeTween should not have its own spline implementation (which will most likely be not suitable for everyone), but it's best for my customers to choose their own third-party splines solution. More info: https://forum.unity.com/threads/1479609/page-4#post-9522451 |
Beta Was this translation helpful? Give feedback.
Huge thanks for the feedback! I'm glad you enjoy using PrimeTween!
I already know how to add this feature seamlessly to PrimeTween, and will add it in the next version.
In the current version, it's already possible with a simple method like this:
While adding this …