bevyengine / bevyengine/bevy

Free Camera Controller: Add ability to snap the free camera to a (user defined) arbitrary position

Open
#23,078 1 comment 0 reactions 0 assignees View on GitHub
A-Camera C-Feature C-Usability D-Modest S-Needs-Design X-Contentious
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## What problem does this solve or what need does it fill?

Sometimes, after wandering around with the free camera, you might want to return to some given camera view. The initial position of the free camera might be one of those positions, but I can also see someone wanting to compare a handful of views that they save while they are flying around. If you accidentally speed far away from your scene, for example, it would be faster if there is a button the user can push that gets you back into a good viewing spot of the scene.

## What solution would you like?

With all the bells and whistles: The user can store three (an arbitrary number) potential `Transform`s that the camera can snap to. The user has the ability to bookmark a spot with a keypress, which pushes it onto this stack of transforms (expiring the oldest one out, or perhaps the user can choose which transform gets overwritten). The user can choose `1` `2` or `3` to automatically snap the camera to one of these positions. The initial position of the camera is set to `1` as a default on free camera controller initialization. The creator of the app can also set init positions if they desire.

A stripped down version: When the free camera state is initialized, save the initial `Transform ` in the free camera state. On some input key pressed, set the camera to that position and reset the yaw and pitch.

## What alternative(s) have you considered?

I’m not sure if this feature is *necessary enough* to support within the free camera, but IMO it would increase usability. I could see the pan camera also benefitting from something like this, but maybe it’s better to just scope it to the free camera for now and then abstract it out when we feel it necessary.

## Additional context

Prior Art: The `debug_frustum_culling` example has some functionality like this, where pressing the `1` key or the `2` key places the free camera into specific defined views. I wondered if generalizing this functionality should be added to the free camera controller itself, so hence this issue being made.

Contributor guide

Open the contributing guide

Research direction

Start by reading the free camera controller entry point and comparing it with the view-switching behavior in the `debug_frustum_culling` example. Clarify whether the initial-position reset or the broader multi-transform bookmarking design is in scope; done should include defined input behavior and camera position, yaw, and pitch reset behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.