Skip to content

[bevy_camera_controller] Implement customisable rotation system for camera movement#22461

Closed
ExtremTechniker wants to merge 5 commits intobevyengine:mainfrom
ExtremTechniker:feature/bevy_camera_controller/customisable-rotation-system
Closed

[bevy_camera_controller] Implement customisable rotation system for camera movement#22461
ExtremTechniker wants to merge 5 commits intobevyengine:mainfrom
ExtremTechniker:feature/bevy_camera_controller/customisable-rotation-system

Conversation

@ExtremTechniker
Copy link

Objective

  • Add support for different movement coordinate systems in the FreeCamera controller.
  • Fix an orientation issue where "forward" and "backward" key bindings were inverted relative to standard conventions.

Solution

  • Introduced RotationSystem enum: Added a configuration option to choose between two movement modes:
    • YawPitchRoll (Default): Movement is relative to the camera's full orientation. Looking up and moving forward moves you "up" in world space.
    • Yaw: Movement is constrained to the horizontal plane. Moving forward always keeps you at the same elevation, regardless of where the camera is looking.
  • Improved Movement Logic: Refactored run_freecamera_controller to use a rotation-based translation instead of manually calculating forward/right vectors.
  • Fixed Inverted Z-Axis: Corrected the forward/back input handling so that key_forward moves the camera along -Z and key_back moves it along +Z, aligning with standard right-handed coordinate systems used in Bevy.

Testing

  • Manual Testing: Verified both RotationSystem modes in a local scene.
    • Confirmed that in Yaw mode, looking straight down and pressing "Forward" moves the camera horizontally.
    • Confirmed that in YawPitchRoll mode, looking straight down and pressing "Forward" moves the camera towards the ground.
  • Reviewer Testing:
    • Attach a FreeCamera component to a camera or use the free_camera_controller example
    • Toggle rotation_system between RotationSystem::Yaw and RotationSystem::YawPitchRoll in the component initialization or via an inspector.
    • Verify that W moves you forward and S moves you backward.

Showcase

This PR adds a new configuration option to the FreeCamera component to control movement behavior.

Click to view usage example
commands.spawn((
    Camera3dBundle::default(),
    FreeCamera {
        // Constrain movement to the floor regardless of look direction
        rotation_system: RotationSystem::Yaw,
        ..default()
    },
));

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Dev-Tools Tools used to debug Bevy applications. D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-Camera User-facing camera APIs and controllers. labels Jan 9, 2026
@ExtremTechniker
Copy link
Author

Hi, I think I have resolved all my issues but CI is still failing. The error is from another crate. Can I do something on my end or do I have to wait til it's fixed in the main branch?
Best regards

@ExtremTechniker
Copy link
Author

Thanks for fixing the main branch. CI is now successful.

What's the normal way now?

@alice-i-cecile
Copy link
Member

Now we need to find two contributors to review and approve this PR :) I'll ask around!

Copy link
Member

@Aceeri Aceeri left a comment

Choose a reason for hiding this comment

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

LGTM!

@alice-i-cecile alice-i-cecile added X-Needs-SME This type of work requires an SME to approve it. M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Jan 13, 2026
@github-actions
Copy link
Contributor

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes.

@alice-i-cecile
Copy link
Member

I'm generally skeptical of adding significant configurability and complexity to these dev-tool cameras. These tools are intended as very simple dev-mode cameras with a limited scope: they should be easy to replace for users / projects that want different behavior.

That said, fixes like:

Fixed Inverted Z-Axis: Corrected the forward/back input handling so that key_forward moves the camera along -Z and key_back moves it along +Z, aligning with standard right-handed coordinate systems used in Bevy.

Improved Movement Logic: Refactored run_freecamera_controller to use a rotation-based translation instead of manually calculating forward/right vectors.

are welcome improvements though, and I would be very happy to review (and likely merge) them in their own PRs.

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

Labels

A-Camera User-facing camera APIs and controllers. A-Dev-Tools Tools used to debug Bevy applications. C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Needs-SME This type of work requires an SME to approve it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants