Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCam3D Look-at behavior doesn't follow target when Follow behavior has dampening enabled. #443

Open
torves opened this issue Jan 2, 2025 · 6 comments

Comments

@torves
Copy link

torves commented Jan 2, 2025

Issue description

When a PhantomCamera3D has both Follow Mode and Look At Mode set, with dampening enabled on Follow Mode, the camera fails to look at a moving target.

This is due to the PhantomCamera3D _interpolate_rotation method using the PCam's position instead of the Godot Camera Node position. The PCam position is not interpolated so it is already in the "final" position the Godot Camera is interpolating towards.

Steps to reproduce

  1. Construct a Node3D scene with a PhantomCamera3D and some 3D primitive object to act as the Follow Target and Look At Target for the PCam.
  2. Set the PCam3D Follow and Look At targets to the primitive object.
  3. Set the PCam3D Follow Parameters to use:
  4. Follow Dampening with values greater than 1 so the effect is more noticeable.
  5. Follow Offset with any reasonable values to view the Follow / Look At target.
  6. Run the scene and move the target object around the scene. You will notice the look at fails to track the target.

(Optional) Minimal reproduction project

No response

@torves
Copy link
Author

torves commented Jan 2, 2025

I've already resolved this issue in a fork commit here.
torves@cda9b0d

This has only been tested using Follow Simple and Look At Simple modes, other modes have not been tested.
If this is satisfactory I can create a pull request for this issue.

Edit:
After testing with other behaviors this will need more work than simply changing it to use the Godot Camera for look at position. This has caused severe stuttering issues I'm still looking into fixing in order to add this tracking behavior.

@ramokz
Copy link
Owner

ramokz commented Jan 6, 2025

Think the initial issue and proposed change looks good, so happy to include that.

Am curious about what the stuttering and other issues you encountered are?

@torves
Copy link
Author

torves commented Jan 7, 2025

Something to do with the camera's position being interpolated based on the PCam position while having the rotation based on the Godot Camera seemed to be the cause of the stuttering issues. I haven't had the time to dive too deeply into it and find out exactly.

Here is a vid of the stuttering issue:
https://github.com/user-attachments/assets/bb0fa240-4e50-4abf-90c2-728e9530a89f

This demo manipulates the Follow Offset property of the PCam, rotating the vector around the look at target and scaling it depending on zoom.

@ramokz
Copy link
Owner

ramokz commented Jan 9, 2025

Yeah, that stuttering looks quite severe.

Are you just using a Simple Follow in the demo?
Asking since, practically, only Third Person Follow should be well suited for rotating around a target like that.

@torves
Copy link
Author

torves commented Jan 10, 2025

Yep thats using Simple Follow. Third Person Follow mostly did what I wanted, but it had some strange side effects that seemed due to it having collision, or with how the spring arm worked.

In my project I ended up doing a different camera style than when I was originally looking into this issue, so no need for a workaround. For now I still think this is a "nice to have" feature, so I may get back to working on it over the next couple weeks and will post anything I find.

@ramokz
Copy link
Owner

ramokz commented Jan 12, 2025

You can disable the collision behavior of the spring arm if you want to if that's where the issue lies.

Generally speaking, the spring arm is an ideal approach for doing any kind of rotation around a target, as you would otherwise have to redo what its core goal is manually, which involves a fair bit of math. Would at least strongly advise not using any other follow mode to achieve that result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants