AddActorWorldRotation isn't working with my Hierarchy

I have a Pickup class that needs a StaticMeshComponent.

I can’t set it to be the root because otherwise I wouldn’t be able to scale, move and rotate it in the Blueprint child class.

So I somewhere that in order to edit the Mesh, I need to make a USceneComponent as root and then attach the StaticMeshComp to it

USceneComponent* SceneComp = CreateDefaultSubobject<USceneComponent>(TEXT("SceneComp"));
PickupMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PickupMesh"));

RootComponent = SceneComp;
PickupMesh->SetupAttachment(SceneComp);

So this is the Hierarchy

https://forums.unrealengine.com/filedata/fetch?id=1370899&d=1508267807

The problem is that AddActorWorldRotation() doesn’t seem to work in the Tick() function

void APickup::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

    FRotator rotation = FRotator(0.f, 1.f, 0.f);
    AddActorWorldRotation(rotation);
}

The StaticMesh in-game is completely motionless.

The only way I found is to write

PickupMesh->AddWorldRotation(rotation);

But this is not what I want!

Together with the StaticMesh, in the future I could add some other components that need to rotate together!

So I need the whole Actor to rotate, not just some components.

What am I doing wrong? Thank you in advance.

Make sure the mobility of the root component is set to Movable. Otherwise if you have source, try to step through the AddActorWorldRotation and see why it’s breaking out early.

I tried

RootComponent = SceneComp;

	RootComponent->SetMobility(EComponentMobility::Movable);
	PickupMesh->SetMobility(EComponentMobility::Movable);

	PickupMesh->SetupAttachment(SceneComp);

But nothing changes.

No, I don’t have the source

USceneComponent* SceneComp = CreateDefaultSubobject(TEXT(“SceneComp”))

Is that what it looks like in your constructor, or do you have a SceneComp variable in your class header? Otherwise, that variable might be locally created. Is there a reason you can’t use AStaticMeshActor as well? This gives the static component as the root, but allows you to edit properties I believe.

I just moved the declaration in the header file and kept the initialization in the constructor… but the result is the same… the actor doesn’t rotate!

Hey -

Please take a look at the attached project. As mentioned, I defined the scene component, static mesh component, and rotator in the header file, then copied the necessary code from your original post into the source file (constructor and tick function). When I added the blueprint to the viewport and entered PIE, the mesh was rotating as expected. One thing I noticed was in your screenshot of the hierarchy, the root component is called “Root Component” however when I copied the code to use locally, the root component was shown as “Scene Comp”. I’m not sure if that’s related but just a difference I noticed. Please let me know how your setup differs or if you have any further questions about this issue.

Sample Project

Cheers

I thank you for the help and effort, but I solved the problem days ago since I didn’t get any answers here… the problem was PickupMesh->SimulatePhysics(true) which, in some way, detached the PickupMesh from the whole Actor.