Hi there. My game drops from 400fps to 260fps when I press any inputs I set in my script. Notice that even having the player static (as in, he’s not moving when I press an input. Only calculations happen) the FPS drop is still here.
Here’s some code:
void Input(){
if (isGrounded && fullControl)
{
inputDir = Vector2.Lerp(inputDir, Vector2.zero, recoverSpeedRate * TimeConstant);
}
if (isGrounded)
{
//Basic input
if (Input.GetKey(KeyCode.W))
{
inputDir.y = 1;
}
if (Input.GetKey(KeyCode.S))
{
inputDir.y = -1;
}
if (Input.GetKey(KeyCode.A))
{
inputDir.x = -1;
}
if (Input.GetKey(KeyCode.D))
{
inputDir.x = 1;
}
}
void SpeedManager()
{
//Sprinting
if (isSprint)
speed = SpeedInterpolation(sprintSpeed, recoverSpeedRate);
//Crouching
else if (isCrouched)
speed = SpeedInterpolation(auxMoveSpeed / 2, recoverSpeedRate);
//Sliding
else if (isSlide)
{
fullControl = false;
if (terrainSlope > 10f)
speed = SpeedInterpolation(speed + Mathf.Abs(transform.position.y), 0.5f);
else
speed = SpeedInterpolation(auxMoveSpeed, 1f);
}
else if (isGrounded)
{
speed = SpeedInterpolation(auxMoveSpeed, recoverSpeedRate);
fullControl = true;
}
}
float SpeedInterpolation(float finalSpeed, float _time)
{
float speedInterpolation = Mathf.Lerp(speed, finalSpeed, _time * TimeConstant);
return speedInterpolation;
}
Hope you can at least help me brainstorm. Any help is appreciated