In C++ I set the UProperty like above picture.
But i cannt edit the Camera property in blueprint, even cannt see…
why!
Did you create the Camera in your .cpp file with CreateDefaultSubobject?
AMyFpsCharacter::AMyFpsCharacter(const FObjectInitializer& PCIP) : Super(PCIP)
{
this->FirstPersonCameraComponent = PCIP.CreateDefaultSubobject(this, TEXT(“FirstPersonCamera”));
this->FirstPersonCameraComponent->AttachTo(this->GetCapsuleComponent());
this->FirstPersonCameraComponent->bUsePawnControlRotation = true;
}
This is what I’m using:
FirstPersonCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT(“MyCamera”));
I also recommend getting rid of “this->”. Everyone knows the context. Also instead of AttachTo, you are using SetupAttachement in the constructor.
If that was helpful, make sure to mark this as answer! <3
You may want to try a few different things.
A.) You can make the class public like this
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera")
class UCameraComponent* FirstPersonCameraComponent;
B.) Make a public accessor for your protected class member
protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera")
class UCameraComponent* FirstPersonCameraComponent;
public:
FORCEINLINE class UCameraComponent* GetFirstPersonCamera() const
{
return FirstPersonCameraComponent;
}
I expect that will get you up and running in the editor.
thx!!!
i found ue4 source code,DEPRECATED(4.12, “This function is deprecated, please use AttachToComponent instead.”)
bool AttachTo(…);
so… thx!