I wanted to shrink a polygon, but because it's shape is like a skewed square, I though of editing each of the 4 points to their half Y position, making them meet at the middle. For that I calculated half their scalar vectors for each point, and I have the following code so far:

``````extends Node2D

for Point in NormalPolygon: #Returns Vector2 of each point.
var HalfwayPoint = Point / 2 #Here later will be just the Point.Y/2
ShrunkPolygon.append(HalfwayPoint)

var i = 0
while i < 3: #Don't know if the points starts at 0 or 1, because normally arrays starts at 0 index.

Shrink(i)
i += 1

func Shrink(i):
\$Tween.interpolate_property(\$Polygon2D,"polygon",\$Polygon2D.polygon[i],ShrunkPolygon[i],2,Tween.TRANS_LINEAR,Tween.EASE_IN_OUT)
\$Tween.start()
``````

In theory it should work, but the problem is that \$Polygon2D.polygon returns a copy of the points, not a reference.

How can I edit the Polygon2D points?

I even though of using just the size, but the square looks like is getting squashed rather than shrinked.

in Engine

Do you want to know how to set the points of a Polygon, or how to animate them with a Tween?
Because it's easy to just set the position of points, but I don't know if it's even possible to animate them with a tween.

Yea, the Tween idea is to animate it smoothly... I have a shader material masked with the polygon2d texture.

So the workaround is to do it with the `AnimationPlayer`, we can keyframe the Polygon2D `PoolVector2Array()`, and it will deform through the frames with the continuous motion, but I don't know why we can't do it through `gdscript` using a `tween`.