Fixed HardHit detection in DefaultCollision.

Issue #141.
This commit is contained in:
Muzychenko Andrey 2022-06-15 09:10:24 +03:00
parent 5e42f37fba
commit eed3662592

View File

@ -60,14 +60,17 @@ bool TCollisionComponent::DefaultCollision(TBall* ball, vector2* nextPosition, v
return false; return false;
} }
bool collision = false;
auto projSpeed = maths::basic_collision(ball, nextPosition, direction, Elasticity, Smoothness, Threshold, Boost); auto projSpeed = maths::basic_collision(ball, nextPosition, direction, Elasticity, Smoothness, Threshold, Boost);
if (projSpeed > Threshold) if (projSpeed > Threshold)
{
loader::play_sound(HardHitSoundId, ball, "TCollisionComponent1"); loader::play_sound(HardHitSoundId, ball, "TCollisionComponent1");
collision = true;
}
else if (projSpeed > 0.2f) else if (projSpeed > 0.2f)
loader::play_sound(SoftHitSoundId, ball, "TCollisionComponent2"); loader::play_sound(SoftHitSoundId, ball, "TCollisionComponent2");
else
return false; return collision;
return true;
} }
void TCollisionComponent::Collision(TBall* ball, vector2* nextPosition, vector2* direction, void TCollisionComponent::Collision(TBall* ball, vector2* nextPosition, vector2* direction,