File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ fn run_camera_controller(
198
198
}
199
199
let cursor_grab = * mouse_cursor_grab || * toggle_cursor_grab;
200
200
201
- // Apply movement update
201
+ // Update velocity
202
202
if axis_input != Vec3 :: ZERO {
203
203
let max_speed = if key_input. pressed ( controller. key_run ) {
204
204
controller. run_speed
@@ -213,11 +213,15 @@ fn run_camera_controller(
213
213
controller. velocity = Vec3 :: ZERO ;
214
214
}
215
215
}
216
- let forward = * transform. forward ( ) ;
217
- let right = * transform. right ( ) ;
218
- transform. translation += controller. velocity . x * dt * right
219
- + controller. velocity . y * dt * Vec3 :: Y
220
- + controller. velocity . z * dt * forward;
216
+
217
+ // Apply movement update
218
+ if controller. velocity != Vec3 :: ZERO {
219
+ let forward = * transform. forward ( ) ;
220
+ let right = * transform. right ( ) ;
221
+ transform. translation += controller. velocity . x * dt * right
222
+ + controller. velocity . y * dt * Vec3 :: Y
223
+ + controller. velocity . z * dt * forward;
224
+ }
221
225
222
226
// Handle cursor grab
223
227
if cursor_grab_change {
You can’t perform that action at this time.
0 commit comments