Professional Documents
Culture Documents
//if the player moves while being knocked back they can influence the distance they
travel
if (knockbackVectorX > 0)
{
if (horizontalMovement > 0)
HDirectionalInfluence = 1.6f;
else if (horizontalMovement < 0)
HDirectionalInfluence = 0.6f;
else
HDirectionalInfluence = 1;
}
else if (knockbackVectorX < 0)
{
if (horizontalMovement < 0)
HDirectionalInfluence = 1.6f;
else if (horizontalMovement > 0)
HDirectionalInfluence = 0.6f;
else
HDirectionalInfluence = 1;
}
if (verticalMovement < 0)
VDirectionalInfluence = 0.6f;
else
VDirectionalInfluence = 1;
//multiplies directional influence by knockback vector
knockbackVectorX *= HDirectionalInfluence;
knockbackVectorY *= VDirectionalInfluence;
//if knockback amount is too low after calculations, set it to a noticeable value
if (knockbackVectorX < knockbackAmount.x * addForceMultiplier && knockbackVectorY <
knockbackAmount.y * addForceMultiplier)
{
knockbackVectorX = knockbackAmount.x * knockbackForce * addForceMultiplier;
knockbackVectorY = knockbackAmount.y * knockbackForce * addForceMultiplier;
}