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

Follow Damping with different values only applies smoothing in the global axis #259

Closed ramokz closed 5 months ago

ramokz commented 5 months ago

Issue description

For 3D scenes

When enabling Follow Damping and supplying different values, e.g. Vector3(0.1, 0.1, 0.6), in the Follow Damping Value property, the damping movement doesn't update the camera's local position consistent once the camera starts moving.

Steps to reproduce

  1. Add a simple PCam3D setup with a movable character
  2. Set a PCam3D follow target to the movable character
  3. Apply a Follow Damping Value with Vector3(0, 0, 0.6)
  4. Observe how the camera follows its target here
  5. Adjust the follow offset so that the PCam3D is sitting diagonally or sideways from its follow target
  6. Readjust the PCam3D's rotation so it points towards its target again

Both examples below has:

Normal Version

https://github.com/ramokz/phantom-camera/assets/5159399/c1d74fdb-cde8-459c-8f9b-97bce030fb27

Issue Version

https://github.com/ramokz/phantom-camera/assets/5159399/b30edd46-5008-4cd9-969a-7bff6896e45d

As seen, the damping is following the global coordinates rather than its local x, y, z positions, which makes the damping value a bit misleading and, likely, not lead to the intended experience.

(Optional) Minimal reproduction project

No response

ramokz commented 5 months ago

There are a few ways I can think of resolving this issue, but none of them seem lead to a perfect solution.

From the issue video example above, if you make damping apply to the camera's local positioning, then that resolves the issue when moving in the x-axis.

image

But conversely, if the camera is slightly tilted to point downwards, like above, then that would mean the y and z-axis damping is now pointing in a local forward and upward axis, which might not be desired either.

Current thinking is to allow the user to set which axis should be local, be it individual axis (e.g. x only) or multiple (e.g. xz only). Though it still feels like it doesn't solve all situations.

ZenithStar commented 5 months ago

What's an application where you would want to have independent dampening magnitudes per axis? The only one I can think of is maybe have higher dampening on the vertical axis in order to accentuate the feeling of falling, but I don't think it works like that.

Video with dampening (0.1, 1.0, 0.1): 2024-04-27 06-30-19.webm

Versus what I'd normally would want (0.1, 0.1, 0.1): 2024-04-27 06-37-34.webm

ramokz commented 5 months ago

Can imagine a few instances where that might be desired, but, obviously, it's entirely dependent on what direction a dev wants for their camera.

@trevorstarick suggested it a little while ago (#255), after it had already been implemented in the 0.7 branch, so maybe there's a particular use-case?

trevorstarick commented 5 months ago

I was originally looking for a way to limit the aggressive-ness of the x-axis follow for a platformer I'm working on.

ramokz commented 5 months ago

Does the current implementation match what you were looking for, or are there any changes you miss?

trevorstarick commented 5 months ago

Yup, it's pretty much the same implementation that I had. I'm still messing around with the core camera design, so if there is anything that I'm missing, I'll probably end up forking and then making a PR for any features I add/extend.

ramokz commented 5 months ago

Nice!

Will close the issue for now as no one has complained about it yet, but anticipate someone will down the line.