var joint = PinJoint2D.new()
joint.set_node_a(get_path())
joint.set_node_b() #this is a problem with instance object
The problem comes with the object instances . The argument of " set_node_a " and " set_node_b " functions takes the path to the object.
But how to do when the object is created at runtime (instance()) ?
Thanks.
-jospic
Resolved: before create joint must be to set a name for object instance
for i in range(NUM_PARTS):
var p = part.instance()
p.set_name("Part"+str(i))
var pospartX = get_pos().x - 24*(i+1)
var pospartY = get_pos().y
p.set_pos(Vector2(pospartX, pospartY))
add_child(p)
for i in range(2,NUM_PARTS):
var j = PinJoint2D.new()
j.set_node_a("Part"+str(i))
j.set_node_b("Part"+str(i-1))
Hello, I am trying to do a rope and I have a similar problem.
In which function did you run that code? the _ready? or _init?