forked from unfa/liblast
Select a randomised spawn point every time the player spawns.
parent
a220840aa2
commit
895607642b
|
@ -12,6 +12,7 @@
|
|||
[ext_resource path="res://Assets/Maps/DM1/OmniFlicker.gd" type="Script" id=10]
|
||||
[ext_resource path="res://Assets/Maps/DM1/SpotFlicker.gd" type="Script" id=11]
|
||||
[ext_resource path="res://Assets/SFX/Ambient_Pipes.wav" type="AudioStream" id=12]
|
||||
[ext_resource path="res://LevelComponents/SpawnPointsManager.gd" type="Script" id=13]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
|
@ -1490,9 +1491,6 @@ height = 84.58
|
|||
|
||||
[node name="Level" type="Spatial"]
|
||||
|
||||
[node name="SpawnPoint" parent="." instance=ExtResource( 9 )]
|
||||
transform = Transform( 0.258819, 0, 0.965926, 0, 1, 0, -0.965926, 0, 0.258819, 2, 10, 18 )
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource( 2 )
|
||||
|
||||
|
@ -1501,10 +1499,14 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 13, 0 )
|
|||
light_data = SubResource( 3 )
|
||||
|
||||
[node name="SpawnPoints" type="Spatial" parent="."]
|
||||
script = ExtResource( 13 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[node name="SpawnPoint" parent="SpawnPoints" instance=ExtResource( 9 )]
|
||||
transform = Transform( 0.258819, 0, 0.965926, 0, 1, 0, -0.965926, 0, 0.258819, 2, 10, 18 )
|
||||
|
||||
[node name="SpawnPoint2" parent="SpawnPoints" instance=ExtResource( 9 )]
|
||||
transform = Transform( 0.258819, 0, 0.965926, 0, 1, 0, -0.965926, 0, 0.258819, 3, 10, -18 )
|
||||
|
||||
|
|
2
Game.gd
2
Game.gd
|
@ -318,7 +318,7 @@ sync func remove_player(id):
|
|||
player.queue_free()
|
||||
|
||||
func get_spawn_point():
|
||||
return $Level/SpawnPoint
|
||||
return $Level/SpawnPoints.get_spawn_point()
|
||||
|
||||
func on_peer_connected(id):
|
||||
print("Peer connected with id ", id)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
extends Spatial
|
||||
|
||||
func spawn(player):
|
||||
player.translation = player.get_parent().to_local(global_transform.origin)
|
||||
player.velocity = Vector3()
|
||||
# Move the player to the starting location.
|
||||
func spawn(player: Player):
|
||||
# Set the player's position and rotation to our position and rotation.
|
||||
player.global_transform = global_transform
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
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()]
|
Loading…
Reference in New Issue