I am trying to let my designers assign a specific type of camera component in the editor rather than hard-coding which camera is being used.
(e.g. I don’t have their soon-to-exist custom camera component, and it might be a BP only one).
I have tried two methods based on threads in the answerhub
Method 1
This is based on the following thread:
1) Set up a new C++ Pawn with a Camera Component
UPROPERTY(Category = "Camera", BlueprintReadWrite)
TSubclassOf<UCameraComponent> Camera;
2) Add a Camera Component Type selection variable
UPROPERTY(Category = "Camera", BlueprintReadWrite)
UClass* CameraType;
3) Construct the given component type and assign it to the camera variable (in pawn constructor)
Camera = CreateDefaultSubobject<CameraType>(TEXT("Camera"));
Is something like this possible? I currently get the following error:
error C2974: 'UObject::CreateDefaultSubobject': invalid template argument for 'TReturnType', type expected
##Method 2
Based on this thread:
1) Set up a new C++ Pawn with a Camera Component
UPROPERTY(Category = "Camera", BlueprintReadWrite)
UCameraComponent* Camera;
2) Construct the given component type and assign it to the camera variable (in pawn constructor)
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
3) Create a blueprint derived from the C++ class (which is BlueprintType)
**4) Show Inherited Variables **
**5) Edit the Camera Component Type from the dropdown **
This doesn’t work, see the attached image: