Modifying the shape.polygon
doesn't work because when you access it you're actually getting a copy of the shape's polygon array. There's a mention in the PoolVector2Array docs about it being passed by value and not by reference.
Reassigning the polygon is the only way to update it when adding or removing points. However it is possible to modify the elements in the array without reassigning:
var polygon = shape.polygon
polygon.resize(4)
polygon.set(0, Vector2(0.0, 0.0))
polygon.set(1, Vector2(50.0, 0.0))
polygon.set(2, Vector2(50.0, 50.0))
polygon.set(3, Vector2(0.0, 50.0))
shape.polygon = polygon
shape.polygon[3].y = 200.0 # this works
I use something like this to add/remove elements:
var new_polygon = shape.polygon
new_polygon.append(Vector2(25.0, 75.0))
new_polygon.append(Vector2(0.0, 75.0))
shape.polygon = new_polygon