ramokz / phantom-camera

👻🎥 Control the movement and dynamically tween 2D & 3D cameras. Built for Godot 4. Inspired by Cinemachine.
https://phantom-camera.dev/
MIT License
2.17k stars 71 forks source link

Inconsistent detection of PhantomCameraHost #267

Closed tiloc closed 4 months ago

tiloc commented 5 months ago

Issue description

I have a scene setup as in this screenshot:

image

In the bottom dock, the Phantom Host tab is telling me that it cannot show a preview, because there is no PhantomCameraHost in the scene. But when I hit the button to add one, I get an error printed to the console that there already is one.

  Only one PhantomCameraHost can exist in a scene
  Multiple PhantomCameraHosts will be supported in https://github.com/MarcusSkov/phantom-camera/issues/26

Steps to reproduce

See Issue description

(Optional) Minimal reproduction project

No response

ramokz commented 5 months ago

My best guess is that it's because you have multiple Camera3D nodes in your scene tree. Since the addon was designed to avoid precisely that, it only looks at the first Camera3D instance. Not that it should necessarily be like that, given what the error also says about there being an option to have multiple hosts in the future. Suspect it might also be partially resolved in 7.1 with the introduction of PhantomCameraManager singleton.

The simplest solution that I can think of right now would be to move the Camera3D, with the PCamHost, to the top of the scene tree so that is the one being read first.

tiloc commented 5 months ago

I am currently looking into using Phantom Camera for 3rd person following, and in the near future group following. I think your algorithms for that are more sophisticated than what I want to code myself. For other situations in the same scene I want the artistic freedom of the pure Godot Camera3D, especially DOF blurring.

I understand the general limitation of only having one PCamHost in the current version. I mainly opened the issue because of the seeming inconsistency between 2 algorithms that determine how many PCamHosts there are in the scene? Maybe there is an opportunity to consolidate this into one?

ramokz commented 5 months ago

Do think there's a way to support your setup, but think it'll be a bit of a pain to get it to detect it correctly with the way the addon is currently structured.

The changes coming with #126 should make that much easier to handle, as it will introduce a PhantomCameraManager singleton, which contains a reference to the Host node. I am not too keen on doing a more complicated fix before that, as it will be effectively somewhat wasted work following that release.

Worth mentioning that the remaining Camera3D property values and environment resources, such as support for DOF, will be added in #127 and #218. Should hopefully remove the need for having other Camera3D in a scene.