Skip to content

3D: Fix camera drifting away when piloting it while in follow mode - #121853

Open
tciviero wants to merge 1 commit into
godotengine:masterfrom
tciviero:fix/camera-followed-and-piloted
Open

tciviero wants to merge 1 commit into
godotengine:masterfrom
tciviero:fix/camera-followed-and-piloted

Conversation

@tciviero

@tciviero tciviero commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

What problem(s) does this PR solve?

Additional information

It is physically impossible to follow and pilot a 3D Camera at the same time. Doing so causes the viewport cursor position to acquire an offset relative to the camera's actual position, resulting in an infinite interpolation loop as the camera continuously tries and fails to catch up to the cursor.

This can be easily proven by zooming in while in follow mode before hitting the pilot button, as this will make the drifting slow as the cursor has a smaller offset that results in a smaller interpolation.

The fix is to disable follow mode before entering pilot mode, while saving the times consecutively focused, in order to restore the follow mode if there was one, after toggling off pilot mode.

@YeldhamDev YeldhamDev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes the issue. Would be nice if it exited the preview already focused instead of snapping to it, but this will do for now.

@YeldhamDev YeldhamDev added the cherrypick:4.7 Considered for cherry-picking into a future 4.7.x release label Jul 28, 2026

@Calinou Calinou left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it mostly works as expected.

However, in certain scenarios, you can still get the original bug to occur:

camera_follow_pilot.mp4

On the above video, I pressed F twice to toggle follow mode at certain points, and the issue eventually occurred depending on what was currently enabled.

I would just disable follow mode as soon as the camera preview mode is entered to avoid the issue.

@tciviero
tciviero force-pushed the fix/camera-followed-and-piloted branch from 5689ea3 to 5fc7806 Compare July 29, 2026 17:53
@Calinou

Calinou commented Jul 29, 2026 •

Copy link
Copy Markdown
Member

With the latest revision of this PR, I can still get the issue to occur with these steps: follow, preview, pilot, unfollow (by pressing F twice).

The issue also occurs when toggling follow mode when both preview and pilot is already enabled, like in master.

@tciviero
tciviero force-pushed the fix/camera-followed-and-piloted branch 3 times, most recently from 0e139ae to 6e54b5b Compare July 30, 2026 09:49
@tciviero

tciviero commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Applying the core fix in focus_selection() introduced a slight side effect: holding F in pilot mode caused the "Following Camera 3D" text to flicker. To prevent this, I appended ... && !previewing_camera) to the condition check that enables follow mode.

Regarding the snapping issue: fixing this safely is complex because the current interpolation system wasn't designed for this specific edge case. Forcing a fix here would risk introducing technical debt. Since it falls outside the immediate scope of this bug, it will be better to address it properly in a PR dedicated to this exact issue.

@tciviero
tciviero requested a review from Calinou July 31, 2026 16:15
@Repiteo Repiteo modified the milestones: 4.8, 4.x Sep 18, 2026

@Calinou Calinou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested again (rebased on top of master e7cfa29), it works as expected.

However, this has the adverse effect of not allowing you to use Focus Selection anymore while piloting a camera, even on another node where it would normally be fine. (Focus and Frame Selection still works, as it's newer than this PR.)

The camera will drift back slightly when you press F (which is the new Focus and Frame Selection option rather than just Focus Selection), but at least it doesn't happen permanently. The camera doesn't move when pressing Focus Selection in comparison. It might be worth looking into fixing this in a follow-up, but it's not critical.

@tciviero
tciviero force-pushed the fix/camera-followed-and-piloted branch from 6e54b5b to 500a183 Compare October 6, 2026 21:53
@tciviero

tciviero commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

This new version of the fix completely removes the Focus and Frame Selection drift, and allows you to use Focus Selection or Focus And Frame Selection on any node that is not a Camera3D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug cherrypick:4.7 Considered for cherry-picking into a future 4.7.x release topic:editor topic:3d

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Camera3D that's Followed, Previewed and Piloted at the same time moves without any input

5 participants