0 votes

I need a parent on a node, so that I can rotate the child using the parents axis without affecting the child's translation.

But I need that same parent's position to change based off another node, without affecting it's children translation. This way the parent can move anywhere I need it, but the child is only affected when the rotation changes.

What is the best way to do this?

asked Dec 30, 2019 in Engine by Dumuz (223 points)

1 Answer

0 votes

You could simply rotate the object programmatically without making it a child. Let's say you want an object called "Satelite" to copy the rotation of another object called "Planet". You open a script, get a referemce to both objects and write under the _process() function:

Satelite.rotation = Planet.rotation

Will this do the trick, or do you need anything more complicated?

answered Dec 30, 2019 by johnygames (1,574 points)

I'm not looking for a copy of a rotation, more so a type of anchor point for the rotation of the satellite.
The script you wrote would make them sit in one place and rotate at the rate.

I'm more in need of having something like; a movable planet that doesn't effect the transform of a satellite, but the satellite will always orbit based off of the position of the planet. Does that make sense?

In this post we have discussed how a Position2D node can be used as that anchor point you are talking about. Have the Position2D copy the planet's rotation using the code provided above. Then make the satellite a child of the Position2D (not a child of the planet).

As the planet moves away, the Position2D will stay in place. When the planet spins, so does the Position2D. Since the satellite is now a child to the Position2D, it will copy its rotation. The thing is that if the satellite and the Position2D have the same center point, they will just pivot around it. But: if the satellite is offset, its rotation will become an orbital motion around the Position2D. Isn't this the desired effect?

Not exactly. Sorry that I'm not explaining it well enough.

So, I have two nodes: A and B.

I want A to be able to translate wherever I need it to go, without effecting B.
I want to then be able to rotate B around A, as if A was the B-nodes anchor point.

My thought process behind the logic is that if node A was a parent of node B, but I can some how mitigated the translation and scale properties of node A. It should give me the desired effect. This way whenever I manipulate the rotation of the node, it would rotate node B around the parent node A, based off the distance between them.

But I am open to other ways of achieving this.

I also have this question, do you find any solution to this?

Hi Constannnnnt,

I didn't find an answer that did exactly what I wanted. My work around to achieve the results I needed was a mixture of vector math help from this guy:


and using both thelook_at() and xform() methods.

What are you trying to do?

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.