Download

How to write a more smooth sliding system?

Hello, I’ve been trying to create a system that slides my character after certain states are performed, I found some code online using Lerp to interpolate two points and move a character there, I adapted it to my game and ended up with this:


 if (LerpTime < RunRecoveryDuration)
{
LerpTime += DeltaSeconds;
FVector NewLoc = FMath::Lerp<FVector>(SlideStartLocation, SlideEndLocation, LerpTime / RunRecoveryDuration);
this->SetActorLocation(NewLoc);
}
else
{

LerpTime = 0;
slide = false;
}

Now, it works pretty well after some testing, but it stops rather suddenly and it feels unnatural, could anyone help me write a more natural slide system?