Skip to content

PhantomCameraHost tries switching to PCams inside PackedScene before it has finished instantiating. #544

@Jack-023

Description

@Jack-023

Issue description

When loading a PackedScene that has a PhantomCamera2D in it's scene tree that has a higher priority than the current pcam, the PhantomCameraHost will set it as the active pcam before the scene has finished instantiating (or before the pcam object itself has even finished loading all of it's properties). This seems like unintended behavior as you probably don't want to switch to a camera before it is added to the scene tree.

I was just trying to log some information about which cameras were being activated when I encountered this but I imagine it will cause problems if a scene is loaded in the background during gameplay before it is needed to be added to the scene.

It seems that this is caused because PackedScene.instantiate() creates the PhantomCamera object, iterates over its properties and sets the values based on the contents of the scene file. When it reaches the priority, it calls the setter function, which finds the PhantomCameraManager singleton and emits its priority_changed signal that is then responded to by the pcam host, which receives a reference to the camera before it has been fully loaded from the file.

Steps to reproduce

I have included a MRP with some logging set up that illustrates the issue.

You can see that new_cam.name is empty when the pcam_became_active signal is received.

(Optional) Minimal reproduction project

repro.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    2DIssues concerning 2D scenes3DIssues concerning 3D scenesbugSomething isn't workingphantom cameraRelated to PhantomCamera nodes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions