system
September 12, 2020, 2:51pm
1
Attention
Topic was automatically imported from the old Question2Answer platform.
Asked By
PipeVerri
I tried with this code in my Node2d:
func _ready():
var node = PinJoint2D.new()
node.set_node_a("part1")
node.set_node_b("part2")
add_child(node)
When i run it, it behaves like there isnt a joint there
system
September 13, 2020, 9:11pm
2
Reply From:
njamster
The NodePaths you’re using are wrong - unless part1 and part2 are children of the PinJoint2D you’re adding via code. If your tree looks like this:
- Root
- part1
- part2
- PinJoint2D (added at runtime)
then the paths have to be “…/part1” and “…/part2” respectively. They have to be relative to the PinJoint-path, not the path of the node who adds the PinJoint.
Thank you, now it works
PipeVerri | 2020-09-13 21:13