feat: implemented recoil
This commit is contained in:
parent
a7b3f97b3b
commit
58e90780d5
6 changed files with 56 additions and 7 deletions
|
|
@ -17,14 +17,20 @@ void PlayerCamera::update_fov() {
|
|||
}
|
||||
}
|
||||
|
||||
void PlayerCamera::ready() {
|
||||
PlayerInput *input{ cast_to<PlayerInput>(get_node(NodePath("%PlayerInput"))) };
|
||||
input->connect(PlayerInput::sig_look_input, callable_mp(this, &self_type::on_look_input));
|
||||
this->base_fov = get_fov();
|
||||
}
|
||||
|
||||
void PlayerCamera::_notification(int what) {
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
return;
|
||||
}
|
||||
if (what == NOTIFICATION_READY) {
|
||||
PlayerInput *input{ cast_to<PlayerInput>(get_node(NodePath("%PlayerInput"))) };
|
||||
input->connect(PlayerInput::sig_look_input, callable_mp(this, &self_type::on_look_input));
|
||||
this->base_fov = get_fov();
|
||||
switch (what) {
|
||||
case NOTIFICATION_READY:
|
||||
ready();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -36,3 +42,9 @@ void PlayerCamera::set_fov_factor(float value) {
|
|||
float PlayerCamera::get_fov_factor() const {
|
||||
return this->fov_factor;
|
||||
}
|
||||
|
||||
void PlayerCamera::recoil(float r) {
|
||||
GETSET(rotation, {
|
||||
rotation.x = CLAMP(rotation.x + r, -Math::PI / 2.0, Math::PI / 2.0);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue