Another alternate solution using FVector::PointsAreNear

Here is the solution I came up with for those interested.

void AMovingPlatform::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	if (HasAuthority())
	{
		if (FVector::PointsAreNear(GetActorLocation(), OriginLocation, MoveSpeed * DeltaTime))
			Direction = (TargetLocation - OriginLocation).GetSafeNormal();
		if (FVector::PointsAreNear(GetActorLocation(), TargetLocation, MoveSpeed *DeltaTime))
			Direction = (OriginLocation - TargetLocation).GetSafeNormal();
		
		FVector Location = GetActorLocation();
		Location += Direction * MoveSpeed * DeltaTime;
		SetActorLocation(Location);
	}
}

Privacy & Terms