DashBoomColorClash/entities/SpawnPoint.gd

31 lines
639 B
GDScript
Raw Normal View History

2024-01-27 18:03:18 +01:00
class_name SpawnPoint extends Node3D
@export var player_index : int = 0
@export var fixed_player : bool = false
var near_players: Array = []
func _ready():
var area3d = $'Area3D'
area3d.connect("body_entered", on_player_enter)
area3d.connect("body_exited", on_player_exited)
func on_player_enter(node: Node3D):
var player: Player = node as Player
if node == null:
return
2024-01-27 23:12:04 +01:00
if near_players.find(player) == -1:
2024-01-27 18:03:18 +01:00
near_players.append(player)
func on_player_exited(node: Node3D):
var player: Player = node as Player
if node == null:
return
near_players.erase(player)
func is_occupied():
return near_players.size() > 0