0 votes

I m making a game in which player runs inside a circle , and the circle opens at random places , I need some help to open the circle at random places .

Your help shall be highly appreciated !

in Engine by (34 points)
recategorized by

There could be many ways to do that.
How did you make player runs inside a circle?

1 Answer

+1 vote

You could make it so each segment of the circle has an id associated with it. Each segment could live under a parent with a script attached that takes an id, and calls open() on whichever child has that id. In code, that might look like:

var segments = {}

func _ready():
    for c in get_children():
        if "id" in c:
            segments[c.id] = c

func open_segment(id):
    segments[id].open()

func open_rand_segment():
    var i = rand_range(0, segments.size())
    open_segment(segments.keys()[i])

Of course, this varies greatly depending on implementation details.

by (98 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 Frequently asked questions and 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 [email protected] with your username.