How do you rotate a static mesh with c++?,How do you rotate a static mesh using c++?

Hi I am new to both c++ and the unreal engine and would greatly appreciate if someone showed me working code that can make an object spin constantly in the game. I have a static mesh for a sword that I want to place in a pillar and make it constantly spin around its Z axis. I tried using both Actor and Pawn classes for it, (I’m not fully sure which one to use) I can get it linked up to the blueprint (Ive just added useless variables that I can pick to so I know if the c++ code is working with the blueprint) but I have no idea how to get the AActor and how to perform the rotation on it.

Did you try timelines?

Now if you don’t want that, simply override the Tick() function.

Get the current local rotation, add a small rotation into the Yaw and set this as the new rotation.

You need to extend it from an Actor (not a Pawn)

And if that sword is imply going to sit on that pillar, rotating for the entire duration for the game, just use Matinee to animate it.

Ok to be more clear, this is what I want to see, sample c++ code for both the .h and .cpp files that will do exactly what these blueprints do, I have no idea how to implement things like this and it would be a huge help.

Have you gone through the youtube C++ tutorial by Unreal Dev team? It is very good start,

Thats the first of a series. You can see the rest in youtube.

Here is my Example:

// Rotate the artifact to identify the importance of the artifact
FRotator ArtifactRotation = GetActorRotation();
float DeltaRotation = DeltaTime * 150.f;
ArtifactRotation.Yaw += DeltaRotation;

// Set the artifact rotation when the player begins the level, false otherwise
SetActorRotation(ArtifactRotation);

This should be places after the the Super::Tick(DeltaTime); Funtion.

Hope this helps!