My focus during this session was to add smooth movement to my character.
Player CPP file
void ACompetitionCharacter::Retreat()
{
PlayerState = "Retreating";
GetWorldTimerManager().SetTimer(MovementHandler, this, &ACompetitionCharacter::ResetControl, 1.0f, false);
This will reset player control once the timer in “Dodge” is concluded.
void ACompetitionCharacter::Tick(float DeltaTime)
{
...
if (PlayerState == "Dodging")
{
SetActorLocation(FMath::VInterpConstantTo(StartLocation, NewLocation, GetWorld()->GetTimerManager().GetTimerElapsed(MovementHandler), 300.f));
}
if (PlayerState == "Retreating")
{
SetActorLocation(FMath::VInterpConstantTo(NewLocation, StartLocation, GetWorld()->GetTimerManager().GetTimerElapsed(MovementHandler), 300.f));
Aside from the camera control, the tick function will now interpolate the player’s movement over time. The destination values are also set accordingly based on if the player is in the process of dodging or retreating to the starting location.