|
|
|
|
Reply From: |
exuin |
This is an old question, but people are still looking at this, so…
Now (3.2.3) you can tween node positions directly with “position:x” and “position:y”.
So you can have:
effect.interpolate_property(node, "position:x", start_x, end_x, 1, Tween.TRANS_LINEAR, Tween.EASE_IN)
effect.interpolate_property(node, "position:y", start_y, end_y, 0.5, Tween.TRANS_QUAD, Tween.EASE_OUT)
effect.interpolate_property(node, "position:y", end_y, start_y, 0.5, Tween.TRANS_QUAD, Tween.EASE_IN, 0.5)
Also, this is for animations where you want the ending y-position to be the same as the starting y-position only. Someone on Discord was trying to use it with a dynamic dropping system like in Enter the Gungeon and it didn’t work. If you want to dynamically set the ending y-position, use this code:
const JUMP_HEIGHT = 96
const ANIM_LENGTH = 0.5
effect.interpolate_property(node, "position:x", node.position.x, ending_pos.position.x, ANIM_LENGTH)
effect.interpolate_property(node, "position:y", node.position.y, ending_pos.position.y-JUMP_HEIGHT, ANIM_LENGTH/2, Tween.TRANS_QUAD, Tween.EASE_OUT)
effect.interpolate_property(node, "position:y", ending_pos.position.y-JUMP_HEIGHT, ending_pos.position.y, ANIM_LENGTH/2, Tween.TRANS_QUAD, Tween.EASE_IN, ANIM_LENGTH/2)
effect.start()
Note that ending_pos is a Position2D node here. You can change it to a Vector2 or whatever you want, though.
Very usefull, thank you.
How can I achieve the same this on a 3D scene?
I have th following aproach, but the result is a mess.
tween.interpolate_property(newBullet, "translation:x", origin.x, target.x, 1, Tween.TRANS_LINEAR, Tween.EASE_IN)
tween.interpolate_property(newBullet, "translation:z", origin.z, target.z, 1, Tween.TRANS_LINEAR, Tween.EASE_IN)
tween.interpolate_property(newBullet, "translation:y", origin.y, target.y, 0.5, Tween.TRANS_QUAD, Tween.EASE_OUT)
tween.interpolate_property(newBullet, "translation:y", target.y, origin.y, 0.5, Tween.TRANS_QUAD, Tween.EASE_IN, 0.5)
punkomalo | 2021-04-30 20:19