The playable character in the scene has a dash function that, once activated, has a specific duration. When I select the object in the inspector it works fine, but when I select another one or play it in a build, the dash duration is always seems to be faster. Does anyone know what the cause of this could be?
{
if (stamina >= 0 + dashCost)
{
//Sound Effekt
DashSound.PlayOneShot(DashSound.clip);
rb.linearVelocity = Vector3.zero;
gravityScale.gravityEnabled = false;
Vector3 dashDirection = transform.forward;
if (Input.GetKey(KeyCode.A))
{
dashDirection = transform.right * -1;
}
if (Input.GetKey(KeyCode.D))
{
dashDirection = transform.right;
}
if (Input.GetKey(KeyCode.S))
{
dashDirection = transform.forward * -1;
}
dashing = true;
rb.AddForce(dashDirection * dashForce, ForceMode.Impulse);
stamina -= dashCost;
staminaUsed = true;
StartCoroutine(DashControl());
}
}
private IEnumerator DashControl()
{
dashDuration = 0;
dashMaxSpeed = dashMaxSpeedSave;
while (dashDuration < dashDurationSave)
{
dashMaxSpeed = Mathf.Lerp(dashMaxSpeedSave, maxSpeed, dashDuration / dashDurationSave);
dashDuration += Time.fixedDeltaTime;
yield return null;
}
gravityScale.gravityEnabled = true;
dashing = false;
}```