How to rotate an Actor?

Hi!

I would like to constantly rotate my actor with URotatingMovementComponent with pivot offset.
I have a blueprint derived from my actor class which contains RotatingMovementComponent (It would be nice to set rotationrate from blueprint and use it in the code).

MyActor.h



UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = UI)
TSubobjectPtr<URotatingMovementComponent> RotatingMovement;


MyActor.cpp (in constructor method)



RotatingMovement = ObjectInitializer.CreateDefaultSubobject<URotatingMovementComponent>(this, TEXT("RotatingMovement"));
RotatingMovement->RotationRate = FRotator(0, 190, 0);
RotatingMovement->PivotTranslation = FVector(0, 0);


So this is how I set it up, but it’s not working as expected. (Rotating constantly). Is this the correct way of rotating actor around some point in space or should I use something else?

Thanks!

You need to set the ‘Updated’ Component of the RotatingMovementComponent. You can set it to the RootComponent to rotate the whole actor:



RotatingMovement->SetUpdatedComponent(GetRootComponent());


But I can’t use GetRootComponent() as parameter for this method, since it only accepts UPrimitiveComponent and root component isn’t component of this type…

I can put in StaticMesh and it’s rotating it, but then the actors transform stays the same.

You have to set the StaticMesh to be Movable


Mesh->SetMobility(EComponentMobility::Movable);