Compare commits

..

No commits in common. "909e83e779cac4d81d065a6e96679c34014881fe" and "7b3c2b5b6f3d5ece10a88e90e1cf1c84ffd41374" have entirely different histories.

4 changed files with 12 additions and 31 deletions

View file

@ -7,24 +7,10 @@ void PlayerCamera::_bind_methods() {
} }
void PlayerCamera::on_look_input(Vector2 input) { void PlayerCamera::on_look_input(Vector2 input) {
// PI / 2.1 to avoid change to the flattened forward vector
static const double LOOK_LIM{ Math::PI / 2.1 };
GETSET(rotation, { GETSET(rotation, {
rotation.x = CLAMP(rotation.x + input.y, -LOOK_LIM, LOOK_LIM); rotation.x = CLAMP(rotation.x + input.y, -Math::PI / 2.1, Math::PI / 2.1);
}); });
global_rotate(Vector3{ 0.f, 1.f, 0.f }, input.x); global_rotate(Vector3{ 0.f, 1.f, 0.f }, input.x);
lead_weapon(input * this->weapon_lead_speed);
}
void PlayerCamera::lead_weapon(Vector2 movement) {
this->weapon_lead_rotation.x += movement.y;
this->weapon_lead_rotation.y += movement.x;
this->weapon_lead_rotation = this->weapon_lead_rotation.normalized() * CLAMP(this->weapon_lead_rotation.length(), -this->weapon_lead_limit, this->weapon_lead_limit);
for (Variant child : get_children()) {
if (Node3D * child3d{ cast_to<Node3D>(child) }) {
child3d->set_rotation(this->weapon_lead_rotation);
}
}
} }
void PlayerCamera::update_fov() { void PlayerCamera::update_fov() {
@ -34,7 +20,7 @@ void PlayerCamera::update_fov() {
} }
void PlayerCamera::update_offset() { void PlayerCamera::update_offset() {
bool const is_running{ this->body->get_is_running() && this->body->is_on_floor() }; bool const is_running{ this->body->get_is_running() };
if (is_running != this->was_running) { if (is_running != this->was_running) {
this->was_running = is_running; this->was_running = is_running;
this->run_bob_time = 0.0; this->run_bob_time = 0.0;
@ -42,8 +28,8 @@ void PlayerCamera::update_offset() {
double wave{ Math::sin(this->run_bob_time) }; double wave{ Math::sin(this->run_bob_time) };
Vector3 offset{ Vector3{ float(wave), float(Math::abs(wave)), 0 } * this->run_bob_amplitude }; Vector3 offset{ Vector3{ float(wave), float(Math::abs(wave)), 0 } * this->run_bob_amplitude };
if (!is_running) { if (!is_running) {
this->run_bob_time = MIN(this->run_bob_time, this->run_bob_blend_out); this->run_bob_time = MIN(this->run_bob_time, this->run_bob_amplitude);
offset = offset.lerp(Vector3(), this->run_bob_time / this->run_bob_blend_out); offset = offset.lerp(Vector3(), this->run_bob_time / this->run_bob_amplitude);
} }
GETSET(position, { GETSET(position, {
Basis const basis{ get_basis() }; Basis const basis{ get_basis() };
@ -103,5 +89,4 @@ void PlayerCamera::recoil(float r) {
GETSET(rotation, { GETSET(rotation, {
rotation.x = CLAMP(rotation.x + r, -Math::PI / 2.0, Math::PI / 2.0); rotation.x = CLAMP(rotation.x + r, -Math::PI / 2.0, Math::PI / 2.0);
}); });
lead_weapon({ 0, 0.02f });
} }

View file

@ -8,7 +8,6 @@ class PlayerCamera : public Camera3D {
GDCLASS(PlayerCamera, Camera3D); GDCLASS(PlayerCamera, Camera3D);
static void _bind_methods(); static void _bind_methods();
void on_look_input(Vector2 input); void on_look_input(Vector2 input);
void lead_weapon(Vector2 movement);
void update_fov(); void update_fov();
void update_offset(); void update_offset();
void ready(); void ready();
@ -32,10 +31,6 @@ private:
double run_bob_time{ 0.0 }; double run_bob_time{ 0.0 };
double run_bob_amplitude{ 0.025 }; double run_bob_amplitude{ 0.025 };
double run_bob_frequency{ 10.0 }; double run_bob_frequency{ 10.0 };
double run_bob_blend_out{ 0.2 };
double weapon_lead_limit{ Math::PI * 0.0075 };
double weapon_lead_speed{ 0.15 };
Vector3 weapon_lead_rotation{ 0, 0, 0 };
}; };
#endif // !PLAYER_CAMERA_H #endif // !PLAYER_CAMERA_H

View file

@ -1,4 +1,6 @@
[gd_scene format=3 uid="uid://dqo1pfy3r00ai"] [gd_scene load_steps=2 format=3 uid="uid://dqo1pfy3r00ai"]
[ext_resource type="Texture2D" uid="uid://dc26l1ync7env" path="res://assets/gui/reticle.svg" id="1_1o2rr"]
[node name="HeadsUpDisplay" type="HeadsUpDisplay"] [node name="HeadsUpDisplay" type="HeadsUpDisplay"]
anchors_preset = 15 anchors_preset = 15
@ -17,6 +19,11 @@ anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="Reticle" type="TextureRect" parent="CenterContainer"]
unique_name_in_owner = true
layout_mode = 2
texture = ExtResource("1_1o2rr")
[node name="Control" type="Control" parent="CenterContainer"] [node name="Control" type="Control" parent="CenterContainer"]
layout_mode = 2 layout_mode = 2

View file

@ -28,9 +28,6 @@ script = SubResource("GDScript_qot2n")
[node name="Hitbox" parent="wretched/Character/Skeleton3D" index="2" node_paths=PackedStringArray("health")] [node name="Hitbox" parent="wretched/Character/Skeleton3D" index="2" node_paths=PackedStringArray("health")]
health = NodePath("../../../../HealthStatus") health = NodePath("../../../../HealthStatus")
[node name="CollisionShape3D2" parent="wretched/Character/Skeleton3D/Hitbox" index="0"]
transform = Transform3D(1, 6.8945504e-21, 0, 6.2038546e-25, 1.0000037, 0, 0, 0, 1.0000037, -2.2362435e-16, 0.35283393, -0.013339132)
[node name="Hitbox" parent="wretched/Character/Skeleton3D/SpineAttach" index="0" node_paths=PackedStringArray("health")] [node name="Hitbox" parent="wretched/Character/Skeleton3D/SpineAttach" index="0" node_paths=PackedStringArray("health")]
health = NodePath("../../../../../HealthStatus") health = NodePath("../../../../../HealthStatus")
@ -38,9 +35,6 @@ health = NodePath("../../../../../HealthStatus")
health = NodePath("../../../../../HealthStatus") health = NodePath("../../../../../HealthStatus")
damage_modifier = 4.0 damage_modifier = 4.0
[node name="CollisionShape3D" parent="wretched/Character/Skeleton3D/HeadAttach/Hitbox" index="0"]
transform = Transform3D(1.0000024, -1.4661055e-09, 2.3283064e-09, 6.548362e-11, 0.9999224, 0.013243848, 4.0745363e-09, -0.013244033, 0.9999193, -4.656613e-10, 1.3035285, -0.014328403)
[node name="CollisionShape3D" parent="wretched/Character/Skeleton3D/BoneAttachment3D/DamageBox" index="0"] [node name="CollisionShape3D" parent="wretched/Character/Skeleton3D/BoneAttachment3D/DamageBox" index="0"]
transform = Transform3D(1, -9.834766e-07, -2.454035e-06, 1.4305115e-06, 0.9999989, -8.145726e-06, 1.8983264e-06, 7.3344854e-06, 1, -0.20908, -5.9604645e-07, -4.7683716e-07) transform = Transform3D(1, -9.834766e-07, -2.454035e-06, 1.4305115e-06, 0.9999989, -8.145726e-06, 1.8983264e-06, 7.3344854e-06, 1, -0.20908, -5.9604645e-07, -4.7683716e-07)