Video Stream player keeps playing in the background

Godot Version

4.3

Question

Does the video stream player always load itself? In my game scene I created an area block that, on a body being entered into it, calls a control node scene containing a video stream player. In control node script I use the _on_video_stream_player_finished to call back the game scene.

Because I think the video stream player keeps playing on the background it keeps reloading the game scene even when nothing has caused it to play.

For more information I have enabled autoplay because or else the video doesn’t seem to play

Knight of Pixel (DEBUG) 2024-08-20 16-32-49

Here the player is on the left. So here it appears to have no issue cause I interacted with the pumpkin. But even if I don’t the video stream is being run on the background so it’ll reload the scene anyway as show here:

Knight of Pixel (DEBUG) 2024-08-20 16-38-09

Here is the code for the how it works:

So when player walks into the area2d scene changes to another scene (memory_scene) as shown. This is the memory scene:

Here when the video finishes playing it goes back to the original game scene.

So my question is how do I make the video play only once when the player interacts with the pumpkin?

Can share more info if needed thanks

But even if I don’t the video stream is being run on the background

when that happens, please go into the Remote tab’s SceneTree and see how it looks like there. Do you have game.tscn AND memory.tscn inside the SceneTree at the same time?

I’d put a breakpoint right before get_tree().change_scene_to_file("res://scenes/game.tscn") and then go from there.

So my question is how do I make the video play only once when the player interacts with the pumpkin?

From your situation here, you remove the entire game scene to change into the memory, then recreate the game scene after the memory is over (which causes the funny camera panning).

The easiest workaround to making the pumpkin only play once is to make use of a global Autoload. Maybe call it “Global” or something. Inside the autoload, you can create variables like var has_seen_memory: bool = false

Then on your memory_cutscene script, you can go with this:

func _on_area_entered(area: Area2D) -> void:
    if area == character.area_2d:
      if Global.has_seen_memory == true: return
      Global.has_seen_memory = true
      print("Showing cutscene")
      [...]
1 Like

when that happens, please go into the Remote tab’s SceneTree and see how it looks like there. Do you have game.tscn AND memory.tscn inside the SceneTree at the same time?

This seems to have highlighted my issue. I kept the memory.tcsn hidden in some node group hence why it was loading in the background. I removed it and now its working fine and only loads when interacting with the pumpkin. Thank you so much!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.