Skip to content

Commit

Permalink
Only need to render the hyperspace viewport once per jump
Browse files Browse the repository at this point in the history
  • Loading branch information
jspahrsummers committed Jun 28, 2024
1 parent e26c59d commit dc44db1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions effects/hyperspace/hyperspace_effect.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extends MeshInstance3D
## Besides being visually interesting, this effect also serves to hide the scene transition, where otherwise nodes would pop in and out.

@export var hyperspace_controller: HyperspaceController
@export var hyperspace_viewport: SubViewport

## An audio clip to play when a hyperspace jump begins.
@export var jump_out_audio: AudioStreamPlayer
Expand Down Expand Up @@ -32,6 +33,7 @@ func _random_rotation() -> Vector3:
)

func _on_jump_started(_destination: StarSystem) -> void:
self.hyperspace_viewport.render_target_update_mode = SubViewport.UPDATE_ONCE
self.rotation = self.initial_rotation
self.scale = self.initial_scale
self.visible = true
Expand Down
5 changes: 4 additions & 1 deletion game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ script = ExtResource("2_v5hns")
follow_target = NodePath("../Player")
starfield_material = ExtResource("3_vksuy")

[node name="HyperspaceEffect" type="MeshInstance3D" parent="MainCamera" node_paths=PackedStringArray("hyperspace_controller", "jump_out_audio") groups=["hyperspace"]]
[node name="HyperspaceEffect" type="MeshInstance3D" parent="MainCamera" node_paths=PackedStringArray("hyperspace_controller", "hyperspace_viewport", "jump_out_audio") groups=["hyperspace"]]
transform = Transform3D(1, 4.15924e-24, -6.97574e-16, -6.97574e-16, 1.19249e-08, -1, 4.15926e-24, 1, 1.19249e-08, 2.08165e-12, 2.08165e-12, -12)
visible = false
layers = 4
Expand All @@ -127,6 +127,7 @@ mesh = SubResource("SphereMesh_sndvt")
skeleton = NodePath("../..")
script = ExtResource("4_bmy66")
hyperspace_controller = NodePath("../../HyperspaceController")
hyperspace_viewport = NodePath("../../HyperspaceViewport")
jump_out_audio = NodePath("AudioStreamPlayer")

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="MainCamera/HyperspaceEffect" groups=["hyperspace"]]
Expand Down Expand Up @@ -174,6 +175,8 @@ far = 20.0
handle_input_locally = false
gui_disable_input = true
size = Vector2i(4096, 2048)
render_target_clear_mode = 1
render_target_update_mode = 0

[node name="HyperspaceCamera" type="Camera3D" parent="HyperspaceViewport" groups=["hyperspace"]]
transform = Transform3D(1, -6.97574e-16, 4.15926e-24, 4.15924e-24, 1.19249e-08, 1, -6.97574e-16, -1, 1.19249e-08, 2.08165e-12, 10, 2.08165e-12)
Expand Down

0 comments on commit dc44db1

Please sign in to comment.