|
|
|
 |
Reply From: |
Diet Estus |
If you must use Tweens
, you could do something like this.
func parabolic_movement(target_node, start_x, end_x, start_y, end_y, duration):
# tween x position linearly across duration
tween1.interpolate_property(target_node, "global_position:x", start_x, end_x, duration, Tween.TRANS_LINEAR, Tween.TRANS_LINEAR)
tween1.start()
# tween y position in two parts, each across duration/2
# first tween upwards and wait for the tween to finish
tween2.interpolate_property(target_node, "global_position:y", start_y, end_y, duration/2, Tween.TRANS_SINE, Tween.EASE_OUT)
tween2.start()
yield(tween2, "tween_completed")
# then tween downwards
tween2.interpolate_property(target_node, "global_position:y", end_y, start_y, duration/2, Tween.TRANS_SINE, Tween.EASE_IN)
tween2.start()
But typically I would just code this kind of movement directly in _physics_process()
using variables to represent velocity, acceleration, and gravity.
Hey, thanks for the answer. I implemented it and it works. You’re right about it being more logical to code a structure for a jump rather than using a Tween.
I experimented with the idea of drawing a line, via the _draw(): function, set its opacity to 0, converting it into a PoolVector2Array, then apply it to a Path2D / PathFollow, which the object would follow. But, I’m not certain how to handle that. It’s a bit more complex, and I’m still learning the optimal use of Godot. I’d honestly rather do that, but apparently I can’t make it work properly.
If you have any ideas for such a “limited”, restrained, one-time jump, I’m listening. It’s not for a player input by the way, it’s a for an player item.
AbstractGameDev | 2019-01-23 15:27