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
1.97k stars 65 forks source link

PhantomCameraHost editor preview malfunction when Host not first child #185

Closed Zaphodious closed 5 months ago

Zaphodious commented 6 months ago

Issue description

If the PhantomCameraHost on a Camera3D is not the first child, the editor preview breaks and an error message is spammed to "Output".

Example error: res://addons/phantom_camera/scripts/panel/viewfinder/viewfinder.gd:351 - Invalid call. Nonexistent function 'get_active_pcam' in base 'MeshInstance3D'

Steps to reproduce

1) Have a camera in a scene with a PhantomCameraHost attached, but with some other type of node as the first child 2) Open the scene in the Godot editor 3) Observe the non-functional "Phantom Camera" preview and the error messages in "Output"

(Optional) Minimal reproduction project

phantomcamera-preview-mrp.zip

Zaphodious commented 6 months ago

The camera seems to work fine in game even if the error is happening. A specific error message (and a specifier in the docs that the Host should be the first child) would make this easier to work around, but if possible I think that being able to have the Host as a child of the Camera3D in any position would allow for the most flexibility.

WeaselOnaStick commented 6 months ago

I'm also getting this error but my main camera doesn't even have any other children other than the host

ramokz commented 6 months ago

Submitted a PR(#189), have a look and see if that works.

Zaphodious commented 6 months ago

Tested, and the viewfinder functions correctly when PhantomCameraHost is not the first child! Thanks!

Zaphodious commented 6 months ago

Wait, I'm now getting an error when I launch my game: res://addons/phantom_camera/scripts/panel/viewfinder/viewfinder.gd:370 - Invalid get index 'Constants' (on base: 'Nil').

ramokz commented 6 months ago

Wait, I'm now getting an error when I launch my game: res://addons/phantom_camera/scripts/panel/viewfinder/viewfinder.gd:370 - Invalid get index 'Constants' (on base: 'Nil').

Can't seem to replicate it when running test scenes? Are you sure it's related to the issue in this ticket?

ramokz commented 5 months ago

Have merged in #189 to get the initial fix in.

Wait, I'm now getting an error when I launch my game: res://addons/phantom_camera/scripts/panel/viewfinder/viewfinder.gd:370 - Invalid get index 'Constants' (on base: 'Nil').

If you're still encountering this problem, please do open another issue and we can have a look at that there.