fix: look_at condition for player movement uses flat_velocity

This commit is contained in:
Sara Gerretsen 2026-05-21 14:18:36 +02:00
parent 567b6682c6
commit 095b2e2498

View file

@ -22,8 +22,9 @@ void PlayerMovementAction::process_movement(bool look_at_movement) {
target_velocity.y = velocity.y;
velocity = velocity.move_toward(target_velocity, delta * actual_acceleration);
Node3D *character{ get_blackboard()->get_character() };
if (!velocity.is_zero_approx()) {
character->look_at(character->get_global_position() + Vector3(velocity.x, 0, velocity.z));
Vector3 const flat_velocity{ velocity.x, 0, velocity.z };
if (!flat_velocity.is_zero_approx()) {
character->look_at(character->get_global_position() + flat_velocity);
}
get_blackboard()->get_player_body()->set_velocity(velocity);
}