You can use 'var tween = create_tween()' directly to create and bind the tween to the node. This is the same as calling 'var tween = get_tree().create_tween().bind(self)' Use the get_tree() version, when you want to decouple the created tween from the node. That way, the tween will continue to operate even if the node that created it is paused, disabled or freed.
oh my god this is so useful. i've put off animation work on a personal project for a MONTH because i thought i'd have to do all sorts of complex math - this is so much simpler than i thought, and much more flexible too
tweens are more dynamic. they can interpolate to other objects whose locations/properties you won't know in advance, and even moving objects and so forth
That's right. Just like @fvhaudsilhvdfs said. Tweens are more dynamic and light-weight. For example, you can use a Tween to animate the camera position to smoothly move and follow the player. They are also great for simple animations. And you can create them very fast. Imagine having to create and manage animation players for all your UI buttons, it gets messy fast. Generally, use animation players for more complex things and things you need to tweak a lot. And Tweens when you just want something simple and fast. I use tweens to animate buttons, UI like health bars and floating things. Mainly things that uses position, rotations, colors, and visibility. And for timers. Performance wise, they are slighly faster then with the animation player. With 32k animated objects. They took about the same to load and execute. AnimationPlayer took avg 61ms with 80ms peaks, 97k objs, 96k nodes. 390 MB RAM. Tweens took avg 40ms with 70ms peaks, 193k objs, 64k nodes. 356 MB RAM.
You can use 'var tween = create_tween()' directly to create and bind the tween to the node.
This is the same as calling 'var tween = get_tree().create_tween().bind(self)'
Use the get_tree() version, when you want to decouple the created tween from the node.
That way, the tween will continue to operate even if the node that created it is paused, disabled or freed.
oh my god this is so useful. i've put off animation work on a personal project for a MONTH because i thought i'd have to do all sorts of complex math - this is so much simpler than i thought, and much more flexible too
Glad you liked it! Sorry about this video's audio. I messed up the EQ and made the voice sound a bit muffled.
Excellent tutorial, clear, concise and informative. Thank you 🙂
Glad you liked it and could understand it :).
I kind think I messed up the audio levels in this video, making the voice a bit too muffled.
Sensei,
This has been in my mind for quite a while, but in what cases is using tween better than animation player and so is the vice versa?
tweens are more dynamic. they can interpolate to other objects whose locations/properties you won't know in advance, and even moving objects and so forth
That's right. Just like @fvhaudsilhvdfs said.
Tweens are more dynamic and light-weight.
For example, you can use a Tween to animate the camera position to smoothly move and follow the player.
They are also great for simple animations. And you can create them very fast.
Imagine having to create and manage animation players for all your UI buttons, it gets messy fast.
Generally, use animation players for more complex things and things you need to tweak a lot.
And Tweens when you just want something simple and fast.
I use tweens to animate buttons, UI like health bars and floating things.
Mainly things that uses position, rotations, colors, and visibility. And for timers.
Performance wise, they are slighly faster then with the animation player.
With 32k animated objects. They took about the same to load and execute.
AnimationPlayer took avg 61ms with 80ms peaks, 97k objs, 96k nodes. 390 MB RAM.
Tweens took avg 40ms with 70ms peaks, 193k objs, 64k nodes. 356 MB RAM.