0 votes

I tried with this code in my Node2d:

func _ready():
  var node = PinJoint2D.new()

When i run it, it behaves like there isnt a joint there

in Engine by (32 points)

1 Answer

0 votes
Best answer

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.

by (10,608 points)
selected by

Thank you, now it works

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.