Tween specific point in Line2D with tween_property[4.0]

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By davidyu


I’m trying to make tween animation to specific point of Line2D.

var tween := create_tween()
tween.tween_property($Line2D, 'points[1]', Vector2(48, 48), 1.0)

but somehow it cannot find points[1], it throws error that type are missed NilVector2.

I tried also to set the whole points array

tween.tween_property($Line2D, 'points', PackedVector2Array([start, end]), 1.0)

but this works without animation.

Does anybody know how to easily animate Line2D with tween?

:bust_in_silhouette: Reply From: davidyu

ok, i found the answer. just need to use tween_method, something like

    var tween = create_tween()
	tween.tween_method(func(interpolate_position: Vector2) -> void:
		$Line.points = [position, interpolate_position],
	from, to, 0.4)

I tried this but it still doesn’t work

thuexetulai24hdanang | 2023-03-24 08:58