system
1
|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
davidyu |
Hi
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 Nil
→ Vector2
.
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?
system
2
|
|
|
 |
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
1 Like
So I have 3 points and I want to draw 3 lines reaching out to the 3 points.
var init_points = [Vector2.ZERO, Vector2.ZERO, Vector2.ZERO, Vector2.ZERO, Vector2.ZERO, Vector2.ZERO, Vector2.ZERO]
var target_points = [Vector2.ZERO, to_local(point1.global_position), Vector2.ZERO, to_local(point2.global_position), Vector2.ZERO, to_local(point3.global_position), Vector2.ZERO, ]
var tween = create_tween()
tween.tween_method(func(points: Array) -> void: $Line.points = points), init_points, target_points, 1)