Skip to content

Conversation

@rossleonardy
Copy link
Contributor

Objective

Solution

  • As written, the freecam's velocity decays by half every loop.
  • Instead, I used smooth_nudge, which takes the time difference into account so that its behavior isn't depended on the fixed main loop's hz.
  • The freecam plugin took a f32 that defaulted to 0.5, and was written so lower numbers would have faster decay. In smooth nudge terms, you could describe this as 64 log 2 at the fixed time step of 64 hz, which is a decay rate of around 44.3.
  • I used 40.0 as this seems like an easily understandable default.
  • This is a breaking change because now higher numbers (instead of lower numbers) supplied to friction, will increase the decay rate. However, all of the examples that use freecamplugin relied on the default() friction value, and it was only recently added, so I think this is okay.

Testing

  • I tested this change in the examples that use freecam;

@janis-bhm janis-bhm added A-Math Fundamental domain-agnostic mathematical operations A-Dev-Tools Tools used to debug Bevy applications. S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-Camera User-facing camera APIs and controllers. labels Oct 8, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 8, 2025
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 8, 2025
@alice-i-cecile alice-i-cecile added this to the 0.18 milestone Oct 8, 2025
@alice-i-cecile
Copy link
Member

Thanks!

Merged via the queue into bevyengine:main with commit 63a70ed Oct 8, 2025
47 checks passed
mate-h pushed a commit to mate-h/bevy that referenced this pull request Oct 22, 2025
  (bevyengine#21464)

# Objective
- Fixes bevyengine#21455 
- Change the behavior of freecam to use smooth nudge instead of an
exponential, per-frame fall off

## Solution
- As written, the freecam's velocity decays by half every loop.  
- Instead, I used smooth_nudge, which takes the time difference into
account so that its behavior isn't depended on the fixed main loop's hz.
- The freecam plugin took a f32 that defaulted to 0.5, and was written
so lower numbers would have faster decay. In smooth nudge terms, you
could describe this as 64 log 2 at the fixed time step of 64 hz, which
is a decay rate of around 44.3.
- I used 40.0 as this seems like an easily understandable default. 
- This is a breaking change because now higher numbers (instead of lower
numbers) supplied to `friction`, will increase the decay rate. However,
all of the examples that use freecamplugin relied on the default()
friction value, and it was only recently added, so I think this is okay.

## Testing

- I tested this change in the examples that use freecam; 
---
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. A-Math Fundamental domain-agnostic mathematical operations S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Friction in free_cam controller doesn't account for delta time

4 participants