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

Decouple FollowModes #254

Open Flynsarmy opened 2 months ago

Flynsarmy commented 2 months ago

Project Type

3D

Feature Description

Separate out the FollowMode code and allow for custom FollowModes to be registered.

Use Cases

I'm finding myself wanting a custom FollowMode but the current system isn't extensible. Here's an example:

https://github.com/ramokz/phantom-camera/assets/334808/9b2e9cc4-ef72-4e22-84f9-e5fb0948967d

I'm using the Framed FollowMode and it's working exactly how I want except I'd like the camera to have a min/max bounding so that it doesn't pan too far to the right/left/up/down and see far outside of the room in the video above. I tried using invisible StaticBodies to restrict camera movement but the camera flies right through them regardless in this mode.

For this reason I wanted to create a BoundFramed FollowMode that is the same as Framed but accepts an AABB property clamping how far the camera is able to move in each direction.

Importance

Medium - the feature would unlock new possibilities, but it's not a showstopper

Usage

Rarely - just a handful of projects can likely benefit from this

(Optional) Proposed Solution

Pull the FollowMode code out of Constants, Properties and 2D/3D classes and move them into their own classes to be called from the previously mentioned as required. Provide a register_follow_mode() function to register new FollowModes.

ramokz commented 2 months ago

I don't think the solution here is a custom Follow Mode, but rather a 3D version of the Limit Node system that the 2D version already supports. The Follow Mode itself shouldn't be what dictates where the camera can or cannot go within a scene. Instead, it ought to be an external source that clamps it, as the behaviour can be desirable from all follow modes — including Framed Follow.

Have been tinkering with the idea of making a similar system for it for 3D scenes, but got a few things planned out before digging into that — in particular #161 as I suspect they would end up sharing a lot of logic.

ZenithStar commented 2 months ago

I like the idea of eventually decoupling logic into their own component Nodes in an eventual version of this add-on, but that's probably several versions off. That's how I write my own custom logic. imageimage