chore: adjusted rotation code

This commit is contained in:
Sara Gerretsen 2026-04-29 20:48:38 +02:00
parent dc34e86391
commit fcc5132223

View file

@ -1,4 +1,5 @@
#include "player_movement_action.h"
#include "core/math/math_funcs.h"
#include "macros.h"
void PlayerMovementAction::_bind_methods() {
@ -20,8 +21,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()) {
get_blackboard()->get_character()->look_at(get_blackboard()->get_character()->get_global_position() + velocity);
character->look_at(character->get_global_position() + velocity);
}
get_blackboard()->get_player_body()->set_velocity(velocity);
}