In my character class i have a static mesh component that i would like to rotate but iv’e tried every solution that came up on Google search, and it either resulted in a crash on start-up or a crash in game. Please help.
You said the class is an AActor right?
Are you using the tick function?
I’m pretty new to this, but just as spazchicken said you could use an Tick function in your actor.
Don’t forget to set up PrimaryActorTick.bCanEverTick = true;
in the actor constructor.
After that you could SetActorRotation(rotation-variable) in the tick function and increment the rotation variable with every tick. You need to make sure to make the incrementation dependent on DeltaTime or else your rotation will change depending on how many frames/sec you have.
I dunno the exact way to do that, I’m just quoting Shadowriver, who has posted a comment on my thread a few hours ago.
This is the basic concept of your tick function:
void AYourActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
Rotation += RotationRate * DeltaTime;
this->SetActorRotation(Rotation);
}
As I said, I dunno if that’s the correct way to make it frame-independent, just my take on it.
Here’s my thread in case you can extract any information from it (Click).
Maybe this helps you in any way.
No i’m not using the tick function, i have a function that gets executed on input and i would like to execute a rotation change on that function call.
Note - i don’t want to change the rotation of the actor, i want to change the rotation of the actor-component.