Since this is a pawn, try setting the control rotation on a controller instead.
GetController()->SetControlRotation(...);
Since this is a pawn, try setting the control rotation on a controller instead.
GetController()->SetControlRotation(...);
Hello,
I’m having trouble getting my player character to rotate and look at another actor.Here is my code:
void AMainCharacter::Died(AMonster* monster)
{
SetMovement(EMovement::Standing);
DisableInput(UGameplayStatics::GetPlayerController(this, 0));
FVector dir = monster->GetActorLocation() - GetActorLocation();
dir.Normalize();
rotateDeath = dir.Rotation();
died = true;
}
In tick function:
if (died)
{
FRotator res = FMath::RInterpTo(GetActorRotation(), rotateDeath, DeltaTime, 2.f);
if (SetActorRotation(res))
{
UE_LOG(LogTemp, Warning, TEXT("%f %f %f"), res.Pitch, res.Yaw, res.Roll);
}
}
Here is the output:
ah ok, I see. I tried using that but the player still does not rotate. It seems like the picth is only getting affected here: