feat: player body now handles movement fov adjustment
This commit is contained in:
parent
b29966ccf7
commit
6c5a24e374
7 changed files with 62 additions and 43 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "player_body.h"
|
||||
#include "health_status.h"
|
||||
#include "macros.h"
|
||||
#include "player_camera.h"
|
||||
#include "player_input.h"
|
||||
#include "weapon_base.h"
|
||||
#include "weapon_inventory.h"
|
||||
|
|
@ -11,6 +12,7 @@ void PlayerBody::_bind_methods() {
|
|||
}
|
||||
|
||||
void PlayerBody::on_child_entered(Node *node) {
|
||||
node->connect("child_entered_tree", callable_mp(this, &self_type::on_child_entered));
|
||||
if (PlayerInput * input{ cast_to<PlayerInput>(node) }) {
|
||||
input->connect(PlayerInput::sig_movement_input, callable_mp(this, &self_type::set_movement_input));
|
||||
input->connect(PlayerInput::sig_look_input, callable_mp(this, &self_type::on_look_input));
|
||||
|
|
@ -23,6 +25,16 @@ void PlayerBody::on_child_entered(Node *node) {
|
|||
if (HealthStatus * health{ cast_to<HealthStatus>(node) }) {
|
||||
this->health = health;
|
||||
}
|
||||
if (PlayerCamera * camera{ cast_to<PlayerCamera>(node) }) {
|
||||
this->camera = camera;
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerBody::process(double delta) {
|
||||
GETSETM(this->camera, fov_factor, {
|
||||
float const target_fov{ get_is_running() ? 1.2f : 1.0f };
|
||||
fov_factor = Math::move_toward(fov_factor, target_fov, float(delta));
|
||||
});
|
||||
}
|
||||
|
||||
void PlayerBody::physics_process(double delta) {
|
||||
|
|
@ -78,6 +90,9 @@ void PlayerBody::_notification(int what) {
|
|||
set_process(true);
|
||||
set_physics_process(true);
|
||||
return;
|
||||
case NOTIFICATION_PROCESS:
|
||||
process(get_process_delta_time());
|
||||
return;
|
||||
case NOTIFICATION_PHYSICS_PROCESS:
|
||||
physics_process(get_physics_process_delta_time());
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue