Best way to make a kinematicbody2d to orbit another?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 9BitStrider

See title. I’m wanting to know how to make a kinematicbody2d node orbit another node. I’m sure sine/cosine movements will be involved, just not sure how to implement them.

I just recently learned of asin() and acos() in the docs, just not sure how to use them to get the effect that I want. I do not want the sprite itself to rotate. Just it’s position.

Figured it out.

offset += 2 * PI * delta / float(rotation_duration)
offset = wrapf(offset, -PI, PI)
			
var new_pos = Vector2()
			
new_pos.x = cos(offset) * radius.x
new_pos.y = sin(offset) * radius.y
position = global_position + new_pos

9BitStrider | 2019-12-28 17:16