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.92k stars 62 forks source link

Script assumes presence of a tween #291

Closed tiloc closed 2 months ago

tiloc commented 2 months ago

Issue description

I want to do hard camera cuts with no tweening when moving from camera to camera. I have therefore deleted the tweening from the inspector. Now I am getting these error messages: res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_3d.gd:945 - Invalid get index 'duration' (on base: 'null instance').

Looking at the source code it seems that something in the code assumes that tweening is always there?

Steps to reproduce

see above.

(Optional) Minimal reproduction project

No response

tiloc commented 2 months ago

FWIW: CineMachine has a predefined tween called "Cut" which simply does a 0 duration hard cut.

ramokz commented 2 months ago

Would just be a case of applying a duration value of 0, no? That's what the 3d_example_scene does.

tiloc commented 2 months ago

Would just be a case of applying a duration value of 0, no? That's what the 3d_example_scene does.

yes, I have re-added the tweens now and set the duration to 0. But I'm still not clear, is having a "Tween Resource" meant to be mandatory? I would either expect the add-on to function without one, or give me a warning when I dare to remove it.

ramokz commented 2 months ago

It's not mandatory per se, but if you don't specify the tween it will have a default duration.

tiloc commented 2 months ago

It's not mandatory per se, but if you don't specify the tween it will have a default duration.

if I look at the source (https://github.com/ramokz/phantom-camera/blob/5e79b9071a1db36a6771225f2276b2d9b944aa66/addons/phantom_camera/scripts/phantom_camera_host/phantom_camera_host.gd#L239) it seems that tween functions are invoked without any check whether a tween actually exists. This will then result in an error here: https://github.com/ramokz/phantom-camera/blob/5e79b9071a1db36a6771225f2276b2d9b944aa66/addons/phantom_camera/scripts/phantom_camera/phantom_camera_3d.gd#L936

ramokz commented 2 months ago

It has a default tween resource applied internally if you don't assign one.

Are you encountering any runtime errors?

tiloc commented 2 months ago

It has a default tween resource applied internally if you don't assign one.

Are you encountering any runtime errors?

I was when I opened the issue. I fetched another copy of my project from GitHub and now the errors are gone... Weird, will close for now, as no longer reproducible. Not sure what Godot's behaviour regarding exports is supposed to be, as I used "Clear" in the inspector to delete that default tween and that's when the errors began to appear. But now I deleted the default tween again and no errors.