Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | andrew.cw |
Hi all,
Below is the description of a test.
- Create a scene called test with a node of “Area2D” followed by a “CollisionShape2D”.
- Set the “Shape” of “CollisionShape2D” as “ConvexPolygonShape2D” with size of “Points” increased to 3.
- Create another scene and attach a script as shown below.
- Turn on “Visible Collision Shapes” under “Debug” option, and run it.
- I expect only t1 is assigned new values and leads to a triangle, while t2 should be nothing on the screen.
- But you will see 2 triangles with exact same shape (different position) on the screen.
- If you add more instances, you will get more identical triangles. And if you modify anyone of the instances, the other one will be changed.
- I’m using Godot v3.2.1
onready var TEST = preload("res://test.tscn")
func _ready():
var t1 = TEST.instance()
add_child(t1)
var p0 = Vector2(0,0)
var p1 = Vector2(100,0)
var p2 = Vector2(100,100)
t1.get_node("CollisionShape2D").shape.points = PoolVector2Array([p0,p1,p2])
var t2 = TEST.instance()
add_child(t2)
t2.position = t1.position + Vector(500,0)
Please help. Thanks in advance.