Rotating Character towads the object it is interacting with

Solved it by doing this:

I combined @eldany.uy and @Shmoopy1701 advices.

void AFPSCharacter::OrientTowardsTarget(AEntrance* Target)
{
	if (Target)
	{
		FVector TargetLocation = Target->GetActorLocation();

		FVector TargetForward = Target->GetActorForwardVector();

		FVector DesiredPosition = TargetLocation + (TargetForward * Distance);

		SetActorLocation(DesiredPosition);

		FRotator TargetRotation = UKismetMathLibrary::FindLookAtRotation(GetActorLocation(), TargetLocation);

		TargetRotation.Roll = 0.0f;
		TargetRotation.Pitch = 0.0f;

		GetController()->SetControlRotation(TargetRotation);
	}
}
2 Likes