Skip to content
Snippets Groups Projects
Commit dc8091d5 authored by Jonathan Kunstwald's avatar Jonathan Kunstwald
Browse files

Disable camera shake when not moving or dead

parent c8d82988
Branches
Tags
No related merge requests found
......@@ -283,7 +283,10 @@ flock::PlayerController::PlayerController(entt::registry<uint32_t> *reg, flock::
void flock::PlayerController::update(float dt, flock::PlayerController::PlayerInput &&input, flock::PhysicsEngine &physics)
{
if (!mAlive)
{
mCamShakeIntensity = 0.f;
return;
}
glow::transform &playerTransform = mRegistry->get<TransformC>(mEntityPlayer).transform;
......@@ -310,10 +313,9 @@ void flock::PlayerController::update(float dt, flock::PlayerController::PlayerIn
mVelocity *= std::pow(mVelocityDamping, dt);
bool boosting = !input.fireDown && input.boostDown; // Only allow boosting while not firing
bool const boosting = !input.fireDown && input.boostDown; // Only allow boosting while not firing
glm::vec3 directionalAcceleration
= glm::vec3(input.directionalInput) * (mEngineSpeed * dt * (boosting ? mBoostMultiplier : 1.f));
glm::vec3 directionalAcceleration = input.directionalInput * (mEngineSpeed * dt * (boosting ? mBoostMultiplier : 1.f));
// Reverse penalty
if (directionalAcceleration.z > 0)
......@@ -327,27 +329,24 @@ void flock::PlayerController::update(float dt, flock::PlayerController::PlayerIn
playerTransform.rotation = mPhysicalRotation;
playerTransform.position += mVelocity * dt;
// Level limits
playerTransform.position = glm::clamp(playerTransform.position, mPlayingFieldMin, mPlayingFieldMax);
// Particle velocity
EmitterC &engineEmitter = mRegistry->get<EmitterC>(mEntityPlayer);
engineEmitter.velocity = mVelocity;
mPosition = playerTransform.position;
mLastMouseYDelta = 0.f;
// Cam Shake
{
if (boosting)
{
if (boosting && glm::length2(input.directionalInput) > 0.1f)
mCamShakeIntensity = glm::lerp(mCamShakeIntensity, 1.f, dt * 3.5f);
}
else
{
mCamShakeIntensity = glm::lerp(mCamShakeIntensity, 0.f, dt * 2.5f);
}
}
}
// Camera
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment