Character teleports far for the intended location

Hi. I’m trying to make seamless portals. The teleport to the target portal seems okay but when it collides on teleported it sends the character further from the intended location

here is the video: Video

When the character collides with the frame it was sent to a different location.

Here is my code for the actor teleportation

void UPortalComponent::TeleportActor(AActor* ActorTeleport)
	if (ActorTeleport == nullptr || PortalActor == nullptr)

	if (TeleportPortal == nullptr)
		TeleportPortal = GetPortalComponentFromActor(PortalActor);

	const FVector NewPosition = URowelMathLibrary::ConvertLocationToOtherActorSpace(ActorTeleport->GetActorLocation(),this, TeleportPortal);
	const FVector NewVelocity = CalculateVelocityOnTeleport(ActorTeleport);

	FHitResult *HitLocation = nullptr;
	ActorTeleport->SetActorLocation(NewPosition, false, HitLocation, ETeleportType::ResetPhysics);

	ACharacter* Character = Cast<ACharacter>(ActorTeleport);

	if (Character != nullptr)
		const FRotator NewRotation = URowelMathLibrary::ConvertRotationToOtherActorSpace(Character->GetControlRotation(), this, TeleportPortal);

		Character->GetCharacterMovement()->Velocity = NewVelocity;
		const FRotator NewRotation = URowelMathLibrary::ConvertRotationToOtherActorSpace(ActorTeleport->GetActorRotation(), this, TeleportPortal);
		ActorTeleport->SetActorRotation(NewRotation, ETeleportType::ResetPhysics);
		ActorTeleport->GetRootComponent()->ComponentVelocity = NewVelocity;


I’m not sure how to approach this problem. Should I do a Capsule trace before teleporting the character/Actor and move it a little bit based on the impact normal of the trace? or is there a way when the capsule collided with something it just snaps back to the nearest position of the collision?