# Rotate an actor Skeletal Mesh component locally

I have an actor similar to a disk which I want to rotate (and I have always problems with transformation).
I want to rotate it in this way:

(this is the first image I have found on google).

I was trying to do this in the Tick function of the actor:

``````    FRotator Rot = GetActorRotation();
// 1080.0f means 3 complete rotations each second
Rot.Yaw += 1080.0f * DeltaSeconds;
SetActorRelativeRotation(Rot);
``````

I though the ActorRelativeRotation could do it but it’s not.
The actor can be initially positioned and rotated in many ways but I always want it to rotate over its local Z axe (like having a constant rotation rate applied in its pitch).
How can this be done in UE4?

what behavior are you getting when you run your tick function?

just for testing,

try

``````Rot.Yaw += 3;
``````

I know this is a good amount from my own experiements.

Rama

Hi Rama, thanks for the answer.
The amount I sum is ok, I can maybe tweak it a little bit but the problem is that the ‘disc’ is not rotating locally.

What I have is a correct behaviour when the disc is rotated as in the above part of this image, but it usually isn’t and when, for example it has a rotation like in the lower left part I get that wrong behaviour while I would like to have the other one:

so let me get this straight

you have skel mesh that when it is by itself, as exported from 3d modeling program, it has its center at the center of the disc and it is level.

when it attached to actor, it is at an odd angle

when rotated in relative space, relative to parent, it goes in wrong axis

if that is all true

just try using pitch or roll instead, as the axis work differently in local space than you might expect

but this is all dependent on your mesh having been exported with its origin its own center of mass.

Rama

Yes, the ‘disc’ is in truth like a ninja star spawned from the hands of the character. When it is spawned it gets the rotation of the socket and, after being launched, it should have a constant rotation rate applied that should make it rotate in the correct way (like showed in the ‘Want this’ part of the image above). Instead it rotates as showed in the ‘Wrong’ part of the image.

I am trying also with pitch and roll but always getting the wrong rotation.
The new rotation is applied starting from its current rotation, what I need is to set a rotation as if it would always been in the default ‘pose’ (the top part of the image above). Sorry if I havn’t been able to be clear enough with this.

once the star is thrown, is it its own Static Mesh Actor?

Then you should use world transformation, not relative.

And you should not add to the rotation directly

use the Transform feature concatenate rotation, otherwise you will get unpredictible results due to current internal Fquat vs FRotator implementation

``````FORCEINLINE void AddToActorRotation(AActor* TheActor, const FRotator& AddRot) const
{
if (!TheActor) return;

FTransform TheTransform = TheActor->GetTransform();