Skip to content

Commit 654f197

Browse files
committed
Improve fall teleport fade effect
- Fade the ColorRect out after being teleported back. Previously, only a fade-in effect was present. - Draw the ColorRect in front of the crosshair to hide it during the fade (if aiming while falling).
1 parent c1c4cc2 commit 654f197

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

‎player/player.gd‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,18 @@ func _ready():
6767
orientation.origin = Vector3()
6868

6969

70-
func _process(_delta):
70+
func _process(delta):
7171
# Fade out to black if falling out of the map. -17 is lower than
7272
# the lowest valid position on the map (which is a bit under -16).
7373
# At 15 units below -17 (so -32), the screen turns fully black.
7474
if transform.origin.y < -17:
7575
color_rect.modulate.a = min((-17 - transform.origin.y) / 15, 1)
7676
# If we're below -40, respawn (teleport to the initial position).
7777
if transform.origin.y < -40:
78-
color_rect.modulate.a = 0
7978
transform.origin = initial_position
79+
else:
80+
# Fade out the black ColorRect progressively after being teleported back.
81+
color_rect.modulate.a *= 1.0 - delta * 4
8082

8183

8284
func _physics_process(delta):

‎player/player.tscn‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ nodes/strafe/node = SubResource( 24 )
197197
nodes/strafe/position = Vector2( -400, -120 )
198198
nodes/walk/node = SubResource( 29 )
199199
nodes/walk/position = Vector2( -400, 40 )
200-
node_connections = [ "state", 0, "strafe", "state", 1, "walk", "state", 2, "jumpup", "state", 3, "jumpdown", "output", 0, "eye_blend", "land", 0, "state", "land", 1, "hardland", "eye_blend", 0, "aim", "eye_blend", 1, "eyes", "aim", 0, "aimdown", "aim", 1, "land", "aim", 2, "aimup" ]
200+
node_connections = [ "state", 0, "strafe", "state", 1, "walk", "state", 2, "jumpup", "state", 3, "jumpdown", "output", 0, "eye_blend", "aim", 0, "aimdown", "aim", 1, "land", "aim", 2, "aimup", "eye_blend", 0, "aim", "eye_blend", 1, "eyes", "land", 0, "state", "land", 1, "hardland" ]
201201

202202
[sub_resource type="CapsuleShape" id=31]
203203
radius = 0.5
@@ -274,7 +274,7 @@ transform = Transform( 0.803991, 0, 0, 0, 0.803991, 0, 0, 0, 0.803991, 0, 0, 0 )
274274
bones/55/bound_children = [ NodePath("GunBone") ]
275275

276276
[node name="GunBone" type="BoneAttachment" parent="PlayerModel/Robot_Skeleton/Skeleton" index="5"]
277-
transform = Transform( 0.897421, -0.247601, 0.365395, -0.262988, -0.964798, -0.00816901, 0.354591, -0.0887302, -0.930816, -0.207098, 1.36135, 0.549705 )
277+
transform = Transform( 0.92223, -0.384448, -0.0436694, -0.0209561, 0.0630829, -0.997796, 0.386401, 0.920989, 0.0501149, -0.207099, 1.39771, 0.464718 )
278278
bone_name = "hand.R"
279279

280280
[node name="ShootFrom" type="Position3D" parent="PlayerModel/Robot_Skeleton/Skeleton/GunBone"]
@@ -355,15 +355,6 @@ __meta__ = {
355355
anims/far = SubResource( 33 )
356356
anims/shoot = SubResource( 34 )
357357

358-
[node name="ColorRect" type="ColorRect" parent="."]
359-
modulate = Color( 1, 1, 1, 0 )
360-
anchor_right = 1.0
361-
anchor_bottom = 1.0
362-
color = Color( 0, 0, 0, 1 )
363-
__meta__ = {
364-
"_edit_use_anchors_": false
365-
}
366-
367358
[node name="Crosshair" type="TextureRect" parent="."]
368359
self_modulate = Color( 1, 1, 1, 0 )
369360
anchor_left = 0.5
@@ -381,6 +372,12 @@ __meta__ = {
381372
"_edit_use_anchors_": false
382373
}
383374

375+
[node name="ColorRect" type="ColorRect" parent="."]
376+
modulate = Color( 1, 1, 1, 0 )
377+
anchor_right = 1.0
378+
anchor_bottom = 1.0
379+
color = Color( 0, 0, 0, 1 )
380+
384381
[node name="SoundEffects" type="Node" parent="."]
385382

386383
[node name="Step" type="AudioStreamPlayer" parent="SoundEffects"]

0 commit comments

Comments
 (0)