How to rotate component via c++

Hello,

I have got spring arm on character and I want it rotate via c++. I’m creating this in constructor:

SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArm"));
	SpringArm->SetupAttachment(RootComponent);
	SpringArm->TargetArmLength = 700.f;
	SpringArm->AddLocalRotation(FRotator(0, -45.f, 0));
	SpringArm->bUsePawnControlRotation = true;	

Using AddLocalRotation() method, but this not rotate.

Where is the problem of rotating? It should work…

Thx man, I will keep it mind, but the url does not work… Error 404

Hi, there! DesiredRotation depends on flags

  • bUsePawnControlRotation
  • bInheritPitch
  • bInheritYaw
  • bInheritRoll

Also on Component Rotation mode - Relative or Absolute.
You can take a look at implementation (https://github.com/EpicGames/UnrealEngine/blob/2bf1a5b83a7076a0fd275887b373f8ec9e99d431/Engine/Source/Runtime/Engine/Private/GameFramework/SpringArmComponent.cpp#L50)