mirror of
https://github.com/thegatesbrowser/godot-multiplayer.git
synced 2025-10-16 02:03:43 -04:00
copy from thegates-jam repo
This commit is contained in:
parent
c1a7ad74e1
commit
1a335de566
523 changed files with 22408 additions and 0 deletions
24
main/spawn_points.gd
Normal file
24
main/spawn_points.gd
Normal file
|
@ -0,0 +1,24 @@
|
|||
extends Node3D
|
||||
class_name SpawnPoints
|
||||
|
||||
var spawn_points: Array[Node]
|
||||
var used_ids: Array[int]
|
||||
var size: int
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
spawn_points = get_children() as Array[Node]
|
||||
size = spawn_points.size()
|
||||
|
||||
|
||||
func get_spawn_position() -> Vector3:
|
||||
var id = 0
|
||||
for x in range(1000):
|
||||
id = randi() % size
|
||||
if not id in used_ids:
|
||||
used_ids.push_back(id)
|
||||
break
|
||||
elif used_ids.size() == size:
|
||||
used_ids.pop_front()
|
||||
|
||||
return spawn_points[id].global_position
|
Loading…
Add table
Add a link
Reference in a new issue