phantom-camera icon indicating copy to clipboard operation
phantom-camera copied to clipboard

Current rotation is always global rotation in Framed mode?

Open Luminoth opened this issue 9 months ago • 3 comments

Hi, I've been digging into some issues I've had with spawning a Framed mode camera at runtime. I saw that there is some ongoing work to refactor this but I did come across some code that has me a bit confused:

https://github.com/ramokz/phantom-camera/blob/9ef20d030691c246954ea6b0339c7e7017d3e89c/addons/phantom_camera/scripts/phantom_camera/phantom_camera_3d.gd#L949

that is setting _current_rotation to be the same as the global_rotation and then immediately checks to see if they're different (they won't ever be). The same check is done a few lines later, where as far as I can see, nothing would have created a difference between them. I'm not sure what the correct fix is supposed to be here but this seems wrong as-is?

Luminoth avatar Jul 01 '25 21:07 Luminoth

It looks like _current_rotation is set to global_rotation in _ready so I'm not sure when, if ever they would be different.

Luminoth avatar Jul 01 '25 21:07 Luminoth

Sorry another couple things, it's not perfect (it seems to ignore damping I think) but changing this:

https://github.com/ramokz/phantom-camera/blob/9ef20d030691c246954ea6b0339c7e7017d3e89c/addons/phantom_camera/scripts/phantom_camera/phantom_camera_3d.gd#L980

to _follow_target_position = _get_target_position_offset_distance() also seems to fix the distance not being setup correctly and changing this:

https://github.com/ramokz/phantom-camera/blob/9ef20d030691c246954ea6b0339c7e7017d3e89c/addons/phantom_camera/scripts/phantom_camera/phantom_camera_3d.gd#L1040

to global_transform.basis.z * follow_distance may or may not be a thing since global transforms are used for everything else.

Luminoth avatar Jul 01 '25 23:07 Luminoth

Sorry, one more, if the camera and the follow target are in the same spot, this breaks everything when it tries to unproject:

https://github.com/ramokz/phantom-camera/blob/9ef20d030691c246954ea6b0339c7e7017d3e89c/addons/phantom_camera/scripts/phantom_camera/phantom_camera_3d.gd#L946

(this is pretty easy to do when spawning at runtime if you're just jamming everything at the origin to start)

And I'm happy to submit a PR on any of this if it seems reasonable and easy to sort out the few weird things like damping not applying.

Luminoth avatar Jul 01 '25 23:07 Luminoth