Topic was automatically imported from the old Question2Answer platform.
Asked By
Anand
Old Version
Published before Godot 3 was released.
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 !
There could be many ways to do that.
How did you make player runs inside a circle?
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.