I added SpringArmComponent in my character. But I can’t assign values to variables.
I have already used #include “GameFramework/SpringArmComponent.h” and #include “Camera/CameraComponent.h”.
What am I doing wrong?
*.h file.
#include "CoreMinimal.h"
#include "Characters/Base_Character.h"
#include "Player_Character.generated.h"
/**
*
*/
UCLASS()
class FG_CPP_API APlayer_Character : public ABase_Character
{
GENERATED_BODY()
UPROPERTY(BlueprintReadOnly, VisibleDefaultsOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
class USpringArmComponent * SpringArm;
}:
*.cpp file
#include "Player_Character.h"
#include "Components/SkeletalMeshComponent.h"
#include "Components/CapsuleComponent.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
// Constructor
APlayer_Character::APlayer_Character()
{
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArm"));
if (SpringArm)
{
SpringArm->SetupAttachment(GetCapsuleComponent());
SpringArm->RelativeLocation = FVector(-20.f, 0.f, 40.f);
SpringArm->TargetArmLength = 0.f;
SpringArm->bDoCollisionTest = false;
SpringArm->bUsePawnControlRotation = true;
SpringArm->bInheritPitch = false;
SpringArm->bInheritRoll = true;
SpringArm->bInheritYaw = true;
}
}