void AMoveSplineAtFixedSpeed::MoveThroughSpline(float DeltaSeconds)
{
CurrentSplineMoveLength
= FMath::Min(SplineLength, CurrentSplineMoveLength + MoveSplineSpeed * DeltaSeconds * ReverseValue);
const FVector CurrentSplineLocation
= SplineComponent->GetLocationAtDistanceAlongSpline(CurrentSplineMoveLength, ESplineCoordinateSpace::World);
const FRotator CurrentSplineRotation
= SplineComponent->GetRotationAtDistanceAlongSpline(CurrentSplineMoveLength, ESplineCoordinateSpace::World);
const FVector NewLocation = CurrentSplineLocation + LocationOffset;
const FRotator NewRotation = CurrentSplineRotation + RotateOffset;
MeshComponent->SetWorldLocation(NewLocation);
if(bRotateWithSpline == true)
{
MeshComponent->SetWorldRotation(NewRotation);
}
if(CurrentSplineMoveLength >= SplineLength)
{
MeshComponent->SetWorldLocation(LastSplinePointLocation);
MeshComponent->SetWorldRotation(LastSplinePointRotator);
bActivate = false;
if(EndActionDelayTime <= 0)
{
SplineEndAction();
}
else
{
GetWorldTimerManager().SetTimer(ResetTimerHandle, this, &AMoveSplineAtFixedSpeed::SplineEndAction, EndActionDelayTime, false);
}
}
}