0 votes

Basically, I'm trying to get a node's position rotated around it's parent, then draw a line from there to a position that isn't important to this question. I see two ways to achieve this, both of which I have no idea how to do:

  1. Use the Vector2.rotated() method on the local position and then translate it into global position.
  2. Rotate the global position relative to the parent node's global position.

It doesn't really matter which way I use, help with either one is appreciated. Thanks!

in Engine by (112 points)

Any chance of providing an illustration of the important points here? For some reason, I can't quite wrap my head around your description...

Sorry, my problem is kinda hard to explain without going on a huge tangent. I have a node with a Position2D inside of it. I want the Position2D's global position rotated relative to the parent node, so that it points towards the mouse position. I hope this helps :/

1 Answer

0 votes

Why not simply parent the item you want to rotate to a node that's aligned with the parent you want to rotate around. With that, you could simply rotate that parent node as needed.

So, if you have something like this:

    Position2D (you want to rotate this around Parent, without rotating Parent itself)

You could do this (for example):

    Node2D (position this at the same location as Parent)
        Position2D (the node to rotate)

Now, to rotate Position2D around Parent, just rotate Node2D as necessary

by (12,477 points)
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.