fix: separated run and weapon bob amplitude

This commit is contained in:
Sara 2025-08-30 13:02:41 +02:00
parent e30758754c
commit f646f70c37
2 changed files with 5 additions and 4 deletions

View file

@ -40,19 +40,19 @@ void PlayerCamera::update_offset() {
this->run_bob_time = 0.0;
}
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 } };
if (!is_running) {
this->run_bob_time = MIN(this->run_bob_time, this->run_bob_blend_out);
offset = offset.lerp(Vector3(), this->run_bob_time / this->run_bob_blend_out);
}
GETSET(position, {
Basis const basis{ get_basis() };
position = this->home + basis.get_column(0) * offset.x + basis.get_column(1) * offset.y * 5.0;
position = this->home + (basis.get_column(0) * offset.x + basis.get_column(1) * offset.y) * this->run_bob_amplitude_camera;
});
for (Variant child : get_children()) {
Node3D *child_3d{ cast_to<Node3D>(child) };
GETSETM(child_3d, position, {
position = offset;
position = offset * this->run_bob_amplitude_weapon;
});
}
}

View file

@ -30,7 +30,8 @@ private:
PlayerBody *body{ nullptr };
bool was_running{ false };
double run_bob_time{ 0.0 };
double run_bob_amplitude{ 0.025 };
double run_bob_amplitude_weapon{ 0.025 };
double run_bob_amplitude_camera{ 0.125 };
double run_bob_frequency{ 14.0 };
double run_bob_blend_out{ 0.2 };
double weapon_lead_limit{ Math::PI * 0.0075 };