feat: Add world border to prevent the player from exiting the level
This commit is contained in:
parent
644ccca0d3
commit
ef6e306b3e
31
level.gd
31
level.gd
|
|
@ -153,6 +153,34 @@ func initialize_world() -> void:
|
||||||
chunk.update()
|
chunk.update()
|
||||||
|
|
||||||
|
|
||||||
|
var wall_n = $WorldLimits/WallN
|
||||||
|
var wall_s = $WorldLimits/WallN.duplicate()
|
||||||
|
$WorldLimits.add_child(wall_s)
|
||||||
|
var wall_e = $WorldLimits/WallN.duplicate()
|
||||||
|
$WorldLimits.add_child(wall_e)
|
||||||
|
var wall_w = $WorldLimits/WallN.duplicate()
|
||||||
|
$WorldLimits.add_child(wall_w)
|
||||||
|
|
||||||
|
wall_n.shape.size = Vector3(
|
||||||
|
Global.chunk_size * dimension,
|
||||||
|
50,
|
||||||
|
1
|
||||||
|
)
|
||||||
|
var WallCenter = Global.chunk_size/2
|
||||||
|
wall_n.position.z = -WallCenter
|
||||||
|
wall_n.position.x = (Global.chunk_size*dimension)/2 - WallCenter
|
||||||
|
|
||||||
|
wall_s.position.z = Global.chunk_size*dimension - WallCenter
|
||||||
|
wall_s.position.x = (Global.chunk_size*dimension)/2 - WallCenter
|
||||||
|
|
||||||
|
wall_e.rotation.y = deg_to_rad(90)
|
||||||
|
wall_e.position.z = (Global.chunk_size*dimension)/2 - WallCenter
|
||||||
|
wall_e.position.x = Global.chunk_size*dimension - WallCenter
|
||||||
|
|
||||||
|
wall_w.rotation.y = deg_to_rad(90)
|
||||||
|
wall_w.position.z = (Global.chunk_size*dimension)/2 - WallCenter
|
||||||
|
wall_w.position.x = -WallCenter
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
|
|
@ -184,4 +212,7 @@ func _on_player_station_reached():
|
||||||
for n in $ChunkContainer.get_children():
|
for n in $ChunkContainer.get_children():
|
||||||
$ChunkContainer.remove_child(n)
|
$ChunkContainer.remove_child(n)
|
||||||
n.queue_free()
|
n.queue_free()
|
||||||
|
for n in $WorldLimits.get_children():
|
||||||
|
if n.name != "WallN":
|
||||||
|
n.queue_free()
|
||||||
initialize_world()
|
initialize_world()
|
||||||
|
|
|
||||||
10
level.tscn
10
level.tscn
|
|
@ -17,6 +17,9 @@ fog_density = 0.0
|
||||||
fog_sky_affect = 0.39
|
fog_sky_affect = 0.39
|
||||||
fog_height = 2.3
|
fog_height = 2.3
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_0b4ue"]
|
||||||
|
size = Vector3(1, 50, 1)
|
||||||
|
|
||||||
[node name="Level" type="Node3D" unique_id=1248504413]
|
[node name="Level" type="Node3D" unique_id=1248504413]
|
||||||
script = ExtResource("1_0b4ue")
|
script = ExtResource("1_0b4ue")
|
||||||
|
|
||||||
|
|
@ -27,7 +30,7 @@ environment = SubResource("Environment_vonw3")
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8361101, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8361101, 0)
|
||||||
|
|
||||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=2083164402]
|
[node name="Camera3D" type="Camera3D" parent="." unique_id=2083164402]
|
||||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 56.95375, 0)
|
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 703.6041, 0)
|
||||||
current = true
|
current = true
|
||||||
fov = 55.0
|
fov = 55.0
|
||||||
script = ExtResource("2_vonw3")
|
script = ExtResource("2_vonw3")
|
||||||
|
|
@ -57,4 +60,9 @@ fov = 55.0
|
||||||
size = 100.0
|
size = 100.0
|
||||||
script = ExtResource("4_0b4ue")
|
script = ExtResource("4_0b4ue")
|
||||||
|
|
||||||
|
[node name="WorldLimits" type="StaticBody3D" parent="." unique_id=697423258]
|
||||||
|
|
||||||
|
[node name="WallN" type="CollisionShape3D" parent="WorldLimits" unique_id=1509447441]
|
||||||
|
shape = SubResource("BoxShape3D_0b4ue")
|
||||||
|
|
||||||
[connection signal="station_reached" from="Player" to="." method="_on_player_station_reached"]
|
[connection signal="station_reached" from="Player" to="." method="_on_player_station_reached"]
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,3 @@ extends Node3D
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
scale *= Global.chunk_size / 150
|
scale *= Global.chunk_size / 150
|
||||||
#$Mesh.mesh.size.x = Global.chunk_size
|
|
||||||
#$Mesh.mesh.size.y = Global.chunk_size
|
|
||||||
#$StationArea/CollisionShape3D.shape.size.x = Global.chunk_size * 0.50
|
|
||||||
#$StationArea/CollisionShape3D.shape.size.z = Global.chunk_size * 0.50
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue