Compare commits
No commits in common. "5bd8b883761842482830839d0244e172fcff7470" and "373d5fcf43aa9565bc253705a7bf8144c686702c" have entirely different histories.
5bd8b88376
...
373d5fcf43
|
@ -15,6 +15,7 @@ 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));
|
||||
input->connect(PlayerInput::sig_jump, callable_mp(this, &self_type::on_jump_input));
|
||||
input->connect(PlayerInput::sig_run, callable_mp(this, &self_type::on_run_input));
|
||||
}
|
||||
|
@ -31,6 +32,7 @@ void PlayerBody::on_child_entered(Node *node) {
|
|||
|
||||
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));
|
||||
});
|
||||
}
|
||||
|
@ -44,14 +46,7 @@ void PlayerBody::physics_process(double delta) {
|
|||
} else {
|
||||
input *= this->walk_speed;
|
||||
}
|
||||
Basis const basis{ this->camera->get_global_basis() };
|
||||
Vector3 forward{ -basis.get_column(2) };
|
||||
forward.y = 0.f;
|
||||
forward.normalize();
|
||||
Vector3 left{ -basis.get_column(0) };
|
||||
left.y = 0.f;
|
||||
left.normalize();
|
||||
velocity = velocity.move_toward(Vector3{ input.y * forward + input.x * left } + Vector3{ 0.f, velocity.y, 0.f }, delta * this->acceleration);
|
||||
velocity = velocity.move_toward(Vector3{ input.y * get_global_basis().get_column(2) + input.x * get_global_basis().get_column(0) } + Vector3{ 0.f, velocity.y, 0.f }, delta * this->acceleration);
|
||||
velocity += get_gravity() * delta;
|
||||
});
|
||||
move_and_slide();
|
||||
|
@ -61,6 +56,10 @@ void PlayerBody::set_movement_input(Vector2 state) {
|
|||
this->movement_input = state;
|
||||
}
|
||||
|
||||
void PlayerBody::on_look_input(Vector2 look) {
|
||||
rotate_y(look.x);
|
||||
}
|
||||
|
||||
void PlayerBody::on_jump_input() {
|
||||
if (this->is_on_floor()) {
|
||||
GETSET(velocity, {
|
||||
|
@ -111,9 +110,6 @@ PackedStringArray PlayerBody::get_configuration_warnings() const {
|
|||
if (find_children("*", WeaponInventory::get_class_static()).is_empty()) {
|
||||
warnings.push_back("This node has no inventory and will cause crashes.\nConsider adding a WeaponInventory node as a child.");
|
||||
}
|
||||
if (find_children("*", PlayerCamera::get_class_static()).is_empty()) {
|
||||
warnings.push_back("This node has no camera of type PlayerCamera, expect crashes.\nConsider adding a PlayerCamera node as a child.");
|
||||
}
|
||||
return warnings;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ class PlayerBody : public CharacterBody3D {
|
|||
void physics_process(double delta);
|
||||
|
||||
void set_movement_input(Vector2 state);
|
||||
void on_look_input(Vector2 look);
|
||||
void on_jump_input();
|
||||
void on_run_input(bool run);
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ void PlayerCamera::on_look_input(Vector2 input) {
|
|||
GETSET(rotation, {
|
||||
rotation.x = CLAMP(rotation.x + input.y, -Math::PI / 2.0, Math::PI / 2.0);
|
||||
});
|
||||
global_rotate(Vector3{ 0.f, 1.f, 0.f }, input.x);
|
||||
}
|
||||
|
||||
void PlayerCamera::update_fov() {
|
||||
|
|
|
@ -66,7 +66,7 @@ void PlayerInput::unhandled_input(Ref<InputEvent> const &event) {
|
|||
}
|
||||
Ref<InputEventMouseMotion> mouse_motion{ event };
|
||||
if (mouse_motion.is_valid()) {
|
||||
Vector2 state{ -mouse_motion->get_relative() * 0.0005f };
|
||||
Vector2 state{ -mouse_motion->get_relative() * 0.001f };
|
||||
emit_signal(sig_look_input, state);
|
||||
}
|
||||
if (event->is_action("primary_fire")) {
|
||||
|
|
|
@ -185,8 +185,6 @@ void Rifle::notify_deselected() {
|
|||
if (HeadsUpDisplay * hud{ HeadsUpDisplay::get_singleton() }) {
|
||||
hud->set_reticle_visibility(true);
|
||||
}
|
||||
this->in_alt_mode = false;
|
||||
this->fov = 0.f;
|
||||
}
|
||||
|
||||
void Rifle::reload_full() {
|
||||
|
|
Loading…
Reference in a new issue