Make camera controller not trigger change detection every frame (#19547)
Split off from https://github.com/bevyengine/bevy/pull/19058
This commit is contained in:
parent
476e644a7d
commit
bebe7c405d
@ -198,7 +198,7 @@ fn run_camera_controller(
|
||||
}
|
||||
let cursor_grab = *mouse_cursor_grab || *toggle_cursor_grab;
|
||||
|
||||
// Apply movement update
|
||||
// Update velocity
|
||||
if axis_input != Vec3::ZERO {
|
||||
let max_speed = if key_input.pressed(controller.key_run) {
|
||||
controller.run_speed
|
||||
@ -213,11 +213,15 @@ fn run_camera_controller(
|
||||
controller.velocity = Vec3::ZERO;
|
||||
}
|
||||
}
|
||||
let forward = *transform.forward();
|
||||
let right = *transform.right();
|
||||
transform.translation += controller.velocity.x * dt * right
|
||||
+ controller.velocity.y * dt * Vec3::Y
|
||||
+ controller.velocity.z * dt * forward;
|
||||
|
||||
// Apply movement update
|
||||
if controller.velocity != Vec3::ZERO {
|
||||
let forward = *transform.forward();
|
||||
let right = *transform.right();
|
||||
transform.translation += controller.velocity.x * dt * right
|
||||
+ controller.velocity.y * dt * Vec3::Y
|
||||
+ controller.velocity.z * dt * forward;
|
||||
}
|
||||
|
||||
// Handle cursor grab
|
||||
if cursor_grab_change {
|
||||
|
Loading…
Reference in New Issue
Block a user