feat: aiming now has zoom effect

main
Sara 2024-12-11 22:42:07 +01:00
parent 83e0d4447f
commit 5d8b312dbd
2 changed files with 5 additions and 0 deletions

View File

@ -1,6 +1,7 @@
#include "player.hpp"
#include "utils/godot_macros.hpp"
#include <godot_cpp/variant/utility_functions.hpp>
#include <godot_cpp/classes/viewport.hpp>
#include <godot_cpp/classes/input_event_joypad_motion.hpp>
void Player::_bind_methods() {
@ -23,6 +24,7 @@ void Player::_ready() {
// setup camera
this->camera_parent = this->get_node<gd::Node3D>("%CameraParent");
this->camera_parent->set_global_rotation(this->get_global_rotation());
this->camera = gd::Object::cast_to<CameraEffects>(this->get_viewport()->get_camera_3d());
}
void Player::_process(double delta) {
@ -42,6 +44,7 @@ void Player::_process(double delta) {
+ (this->is_on_floor() ? gd::Vector3{} : gd::Vector3{0.f, -0.05f, 0.f}) // add some gravity if required
};
this->set_velocity(motion / delta); // velocity has to be in m/s, root motion is framerate-dependent. meters/second=distance/time.
this->camera->push_zoom_effect(this->anim_tree->match_tags(PlayerAnimTree::Tags::Aim) ? .7f : 1.f, 100.f);
}
void Player::_physics_process(double delta [[maybe_unused]]) {

View File

@ -1,6 +1,7 @@
#ifndef TR_PLAYER_HPP
#define TR_PLAYER_HPP
#include "camera_effects.hpp"
#include "damageable_entity.hpp"
#include "player_anim_tree.hpp"
#include "utils/player_input.hpp"
@ -29,6 +30,7 @@ public:
private:
PlayerAnimTree *anim_tree{nullptr};
gd::Node3D *camera_parent{nullptr};
CameraEffects *camera{};
utils::PlayerInput *input{nullptr};
gd::Node3D *model_node{nullptr};
gd::Vector2 input_directions{0.f, 0.f};