0 votes


I am making a 2D game I originally created in Construct. One thing Construct has which is great, is the "Pin" behaviour. You can just pin one object to another, and it rotates and moves with it. I am trying to achieve the same in Godot. I am reparenting a node (a dagger sprite) to another node (a spinning target), but while it does reparent - the position goes out of the window. How do I ensure the dagger remains pinned at the right position as if the dagger stuck into the spinning target? I am assuming I have to convert the daggers world co-ordinates into local co-ordinates within the new parent node? I see there is a PinJoint2D but I am not using physics at all. I expect its made even more difficult by the fact the new parent is constantly rotating.



in Engine by (42 points)

1 Answer

+1 vote

you can easyly convert locals to globals and vize versa with toglobal() and tolocal()


this would transform the daggers world position to the new_parents local position

by (3,932 points)

Thanks, now the rotation is off...

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 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 webmaster@godotengine.org with your username.