Rotate on Pivot

I’m looking to rotate an actor based on an arbitrary world-space pivot. (I am building an in-game grid where each tile is a a decal actor spawned by an overall “grid box” actor)

I’d normally jump to matrix transforms, though I can’t seem to understand how to convert a Rotator to a matrix transform.

How would I go about doing this in UE4?

Thanks in advance.

Hi, FRotationMatrix has a constructor that takes an FRotator:

FRotationMatrix(const FRotator& Rot)

Is that what you were looking for?

Gah, I’m surprised I hadn’t found such an obviously named function, thank you.

Unless there’s a more straight forward way to set an actor’s pivot and rotate about it, I believe this is what I was looking for.

I will try it out when I get home

EDIT: FTranslationMatrix and FRotationMatrix were definitely the functions I was looking for, thanks again!

You might find FVector::RotateAngleAxis might do what you want if you specifically want to rotate a position around an axis.

^Is there any way I could persuade you to show me an example of how to actually use FVector::RotateAngleAxis? I can’t figure it out or find an example for the life of me :confused: I’m trying to make one object orbit another.

Without having tested it, I would have thought the following should rotate “Actor” 'round the up vector of “OrbitActor”:

const FVector ActorPosition = Actor->GetActorLocation();
const FVector NewActorLocation = ActorPosition.RotateAngleAxis(90.f, OrbitActor->GetActorUpVector());

Actor->SetActorLocation(NewActorLocation);

THANK YOU SOOOOO MUCH!!!