Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | stephandischer |
Hello eveyone,
just came across some unexpected behaviour, which is messing with my understanding of how generally scenes suppose to work.
I created a simple scene which basically only contains a Path2D Node.
I noticed that all instances from that scene created from scripts share the same curve instance which is used in the Path2D node.
So here is what I am wondering about in a nutshell:
var MyPath2D = preload("res://MyPath2D.tscn")
var p1 = MyPath2D.instance()
var p2 = MyPath2D.instance()
p1.get_curve().add_point(Vector2(1,1))
print(p1.get_curve().get_point_count()) # returns "1"
print(p2.get_curve().get_point_count()) # returns "1"
Whereas when I am trying the same thing with a Path2D node directly with new() instead of instance() I am getting the results I would expect:
var p3 = Path2D.new()
var p4 = Path2D.new()
p3.get_curve().add_point(Vector2(1,1))
print(p3.get_curve().get_point_count()) # returns "1"
print(p4.get_curve().get_point_count()) # returns "0"
Am I missing some fundamental understanding here or should I consider this to be a bug?
Appriciate your thoughts on the matter. I can think about various workarounds for my case, however just wondering about the general concept here.