This repository has been archived on 2022-01-09. You can view files and clone it, but cannot push or open issues/pull-requests.
liblast/LevelComponents/SpawnPointsManager.gd

17 lines
489 B
GDScript

extends Spatial
onready var spawn_points = get_children()
# Return an available spawn point.
func get_spawn_point(index: int = -1):
# If index is negative, return a randomly chosen spawn point.
if index < 0:
return spawn_points[randi() % spawn_points.size()]
# If index is positive, return a specific spawn point.
# This is mostly for debugging.
else:
# Take the modulo of the index argument, in case the number is too high.
return spawn_points[index % spawn_points.size()]