Added SpawnPoints

This commit is contained in:
Martin Felis
2024-01-27 18:03:18 +01:00
parent 9c4dfcd657
commit eff6a69855
5 changed files with 106 additions and 5 deletions
+4
View File
@@ -60,6 +60,10 @@ func _physics_process(delta):
state = PlayerState.Falling
elif state != PlayerState.Dead:
state = PlayerState.Alive
elif state == PlayerState.Dead:
visible = false
elif state == PlayerState.Alive:
visible = true
coloring_sprite.visible = state == PlayerState.Alive
+30
View File
@@ -0,0 +1,30 @@
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
if not near_players.find(player):
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
+27
View File
@@ -0,0 +1,27 @@
[gd_scene load_steps=4 format=3 uid="uid://cc521i07ajufm"]
[ext_resource type="Script" path="res://entities/SpawnPoint.gd" id="1_l0ld5"]
[sub_resource type="CylinderMesh" id="CylinderMesh_8id3y"]
top_radius = 0.3
height = 0.1
radial_segments = 5
[sub_resource type="CylinderShape3D" id="CylinderShape3D_1ha80"]
height = 1.0
radius = 1.0
[node name="SpawnPoint" type="Node3D"]
script = ExtResource("1_l0ld5")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0239549, 0)
mesh = SubResource("CylinderMesh_8id3y")
[node name="Area3D" type="Area3D" parent="."]
collision_layer = 0
collision_mask = 4
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
shape = SubResource("CylinderShape3D_1ha80")