Godot Version
4.2.1
Question
I have a simple program that spawns a single Polygon2D.
I can substitute Polygon2D.polygon for a PackedVector2Array, but I cannot append a vertex. Since substituting it for a different PackedVector2Array works, it does not seem to be immutable after the first assignment.
Why is this and where can I get information about things like this? (I am new to this)
(edited for better readability)
extends Node2D
# Called when the node enters the scene tree for the first time.
func _ready():
var polygon = Polygon2D.new()
var points = PackedVector2Array()
points.append(Vector2(0,0))
points.append(Vector2(100,0))
points.append(Vector2(100,100))
var points2 = PackedVector2Array([Vector2(420,200),Vector2(0,300),Vector2(0,0)])
polygon.polygon = points
print(polygon.polygon) # [(0, 0), (100, 0), (100, 100)]
polygon.polygon.append(Vector2(200,280)) # this does not seem to do anything
print(polygon.polygon) # [(0, 0), (100, 0), (100, 100)]
polygon.polygon=points2
print(polygon.polygon) # [(420, 200), (0, 300), (0, 0)]
polygon.offset = Vector2(100,100)
polygon.color = Color(1,1,1)
add_child(polygon)
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass