Cannot manipulate FirstPersonCameraComponent

Ok, so I set my Character up with a Camera component.


/** First person camera */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera")
	class UCameraComponent* FirstPersonCameraComponent;

Constructor:



/* Create the camera component */
FirstPersonCameraComponent = PCIP.CreateDefaultSubobject<UCameraComponent>(this, TEXT("FirstPersonCamera"));
FirstPersonCameraComponent->AttachParent = GetCapsuleComponent();
// Position the camera a bit above the eyes
FirstPersonCameraComponent->RelativeLocation = FVector(0, 0, 50.0f + BaseEyeHeight);
// Allow the pawn to control rotation.
FirstPersonCameraComponent->bUsePawnControlRotation = true;

The blueprint for that character looks like this.
ef0866e3d148cbec2f2bb7bf37e0624f.png

I cannot make the Camera Movable or change anythign on the camera. When I try to manipulate the camera from C++ it fails as well.


if (Player->FirstPersonCameraComponent) {
	Player->FirstPersonCameraComponent->SetRelativeLocation(FVector(0, 0, 0));
}

It never process the statement inside the if, because the CameraComponent seems to be zero.

What am I doing wrong here?

Components shouldn’t be editable/blueprint writable. What it basically means is “the pointer to this component is editable” when what you want is “the contents of this component are editable”. The property editor automagically handles that distinction when you make components Visible:


/** First person camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera")
class UCameraComponent* FirstPersonCameraComponent;

That should let you view and edit camera propetties, at least.

Note that based on what you’re saying, your blueprint was saved with a null component thanks to it being editable. Either restore it to defaults before doing the above code change, or just recreate your blueprint from scratch if you can, so the defaults are recreated.

Thank you so much. I wasted like 3hours on that now…thanks.