0 votes
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

The above code works for one node. How to I spread it evenly between multiple nodes orbiting a single object or point in my game? Trying to make a ring menu like in Secret of Mana.

Godot version 3.2.3
in Engine by (197 points)

I managed to get it working how I want. Now the problem is stopping the icons at a certain angle. Here is the code I'm using:

var rotate = true
var rot_dir = 1
var radius
var rotate_dur = 1.0
var dist = Vector2(60, 10)
var chars = []
var orbit_ang_offset = 0

func process(delta):
    if rotate:
        radius = Vector2.ONE * dist

        orbit_ang_offset += (2 * rot_dir) * PI * delta / float(rotate_dur)
        orbit_ang_offset = wrapf(orbit_ang_offset, -PI, PI)

        if chars.size() != 0:
            for i in chars.size():
                var spacing = 2 * PI / float(chars.size())
                var new_position = Vector2()
                new_position.x = cos(spacing * i + orbit_ang_offset) * radius.x
                new_position.y = sin(spacing * i + orbit_ang_offset) * radius.y
                chars[i].position = new_position

What I want them the icons to do is stop at the bottom of the orbit, meaning the icon is highlighted and ready for selection. How would I do this?

Please log in or register to answer this question.

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.