SetActorRelativeRotation setting as world

I’m currently creating a movement script for pawn where the rotation is Slerped based on what keys are pressed and the rotation of the camera, as well as the normal of a slope. However the angle is set on world, even though i use SetActorRelativeRotation. This causes the rotation to work not as intended and the angle pivots on the worlds upward vector, and not the actor’s.

FHitResult hit1;
	GetWorld()->LineTraceSingleByChannel(hit1, GetActorLocation() + FVector(0, 0, -47), GetActorLocation() + FVector(0, 0, -97), ECC_Visibility);
	DrawDebugLine(GetWorld(), GetActorLocation() + FVector(0, 0, -47), GetActorLocation() + FVector(0, 0, -97), FColor(255, 0, 0),true);

	newRotation = FRotator(0, angle, 0) + FRotator(0, camera->GetComponentRotation().Euler().Z, 0) + FRotator(hit1.Normal.Rotation().Pitch, 0, 0);

	if(forward != 0 || right != 0)
		SetActorRelativeRotation(FQuat::Slerp(GetActorRotation().Quaternion(), newRotation.Quaternion(), 0.05f));

When you click on the little arrow in the Actor’s Rotation setting in the details panel, is it set to Relative or World?

Not sure, but I think you’re confusing relative transform and local transform. “Relative” is relative to whatever the actor is attached to (or the world if the actor is not attached to anything). “Local” is relative to the actor’s current transform.

Ah so is there a function to set the rotation locally instead of in world space?

I’ve checked both and the values are the same

I think you are looking for something like AddActorLocalRotation()

As dbouchoff statet, RelativeRotation is always relative to the parent. And if your Actor is not attached to something, it is always relativ to the World, therfore it is in world space.

Edit, if you are looking for the c++ implementation of it, you can right-click the BP node and goto the c++ implementation.

I’ve tried that too, but it doesn’t set the value, it adds to the current one making it spin out

AddActorLocalRotation sets the rotation with respect to the current rotation. But note that if you do it twice, the rotation the second time is with respect to where the actor was after the first part of the rotation. Assuming newRotation is the eventual rotation you want in local space, I think what you mean to do is to first compute the final rotation (use ComposeRotators(GetActorRotation(), newRotation)) and then slerp between the actor’s starting rotation and that rotation.

Are you calling this every frame? If you do, it is much easier to compute a DesiredRotation and then smootly interp to this rotation every frame.

FMath::RInterTo() should give you decent results.