Switched to Godot's range fade

This commit is contained in:
Eduard Urbach 2024-02-17 23:18:50 +01:00
parent cf876a0ab8
commit d5681e5dbb
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
4 changed files with 7 additions and 14 deletions

View File

@ -20,7 +20,7 @@ attributes = ExtResource("3_olar0")
current = true
fov = 45.0
size = 10.0
far = 150.0
far = 120.0
script = ExtResource("2_pwdc2")
[node name="CameraRays" type="Node3D" parent="Pivot"]

View File

@ -65,8 +65,10 @@ shape = SubResource("SphereShape3D_s5ct7")
[node name="HUD" parent="." node_paths=PackedStringArray("health") instance=ExtResource("3_4jtio")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.986405, 0)
visible = false
layers = 256
visibility_range_end = 50.0
visibility_range_end_margin = 10.0
visibility_range_fade_mode = 1
health = NodePath("../Health")
[node name="Animation" type="AnimationPlayer" parent="."]
@ -91,6 +93,5 @@ drop = ExtResource("7_i0rtb")
[node name="Visibility" parent="." node_paths=PackedStringArray("health", "hud") instance=ExtResource("9_ssc7p")]
health = NodePath("../Health")
hud = NodePath("../HUD")
hud_distance = 50.0
physics_distance = 50.0
render_distance = 100.0

View File

@ -70,13 +70,9 @@ script = ExtResource("1_8gebs")
[node name="Armature" parent="Model/Female" index="0"]
transform = Transform3D(0.999999, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.000305099, -0.000408816)
[node name="Body" parent="Model/Female/Armature/GeneralSkeleton" index="0"]
[node name="Chest" parent="Model/Female/Armature/GeneralSkeleton" index="1"]
visible = false
[node name="Face" parent="Model/Female/Armature/GeneralSkeleton" index="2"]
[node name="Hips" parent="Model/Female/Armature/GeneralSkeleton" index="3"]
visible = false
@ -106,6 +102,9 @@ shape = SubResource("CapsuleShape3D_2f50n")
[node name="HUD" parent="." node_paths=PackedStringArray("health") instance=ExtResource("7_fwgtd")]
layers = 512
visibility_range_end = 50.0
visibility_range_end_margin = 10.0
visibility_range_fade_mode = 1
health = NodePath("../Health")
[node name="Attractor" type="GPUParticlesAttractorSphere3D" parent="."]

View File

@ -3,7 +3,6 @@ extends Node
@export var health: HealthComponent
@export var hud: HUDComponent
@export var hud_distance: float
@export var physics_distance: float
@export var render_distance: float
@ -12,15 +11,10 @@ var main_player_distance_sq: float
func _ready():
parent = owner
hud_distance *= hud_distance
physics_distance *= physics_distance
render_distance *= render_distance
update_visibility()
func _process(_delta):
if hud.visible:
hud.transparency = 1.0 - (hud_distance - main_player_distance_sq) * 0.001
func update_visibility():
if !Global.player:
return
@ -30,5 +24,4 @@ func update_visibility():
main_player_distance_sq = parent.global_position.distance_squared_to(Global.player.global_position)
parent.visible = main_player_distance_sq < render_distance
hud.visible = main_player_distance_sq < hud_distance
DeathComponent.set_physics(parent, main_player_distance_sq < physics_distance)