Here's my scene layout and code:
fn physics_process(&mut self, delta: f64) {
let mut chara = self.base_mut();
let mut velocity = chara.get_velocity();
let transform = chara.get_transform();
let delta = delta as f32;
let input = Input::singleton();
if !chara.is_on_floor() {
velocity.y -= GRAVITY * delta
} else if input.is_action_pressed("ui_select") {
velocity.y = JUMP_HEIGHT
}
let input_dir = (input.get_axis("ui_left","ui_right"),input.get_axis("ui_up","ui_down"));
let direction = (transform.basis * Vector3::new(input_dir.0, 0., input_dir.1)).normalized_or_zero();
if direction != Vector3::ZERO {
velocity.x = direction.x * SPEED;
velocity.z = direction.z * SPEED
} else {
velocity.x = move_toward(velocity.x as f64, 0., SPEED as f64) as f32;
velocity.z = move_toward(velocity.z as f64, 0., SPEED as f64) as f32
}
chara.set_velocity(velocity);
chara.move_and_slide();
}