Im creating a child to Character that when used as a blueprint base adds a camera and Enhanced Inputs, however when I create a blueprint with it it doesn’t have any of the added items. There are no errors coming up within the code, whats going on?
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "InputActionValue.h"
#include "PlayerCharacter.generated.h"
UCLASS()
class SHADOWOFTHEBIGPEOPLE_API APlayerCharacter : public ACharacter
{
GENERATED_BODY()
UPROPERTY(VisibleAnywhere, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* Camera;
public:
// Sets default values for this character's properties
APlayerCharacter();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
protected:
UPROPERTY(EditAnywhere, Category = "EnhancedInput")
class UInputMappingContext* InputMapping;
UPROPERTY(EditAnywhere, Category = "EnhancedInput")
class UInputAction* MoveAction;
UPROPERTY(EditAnywhere, Category = "EnhancedInput")
class UInputAction* JumpAction;
UPROPERTY(EditAnywhere, Category = "EnhancedInput")
class UInputAction* LookAction;
void Move(const FInputActionValue& InputValue);
void Look(const FInputActionValue& InputValue);
void Jump();
};
#include "ShadowOfTheBigPeople/PlayerCharacter.h"
#include "InputMappingContext.h"
#include "EnhancedInputSubsystems.h"
#include "EnhancedInputComponent.h"
#include "Camera/CameraComponent.h"
// Sets default values
APlayerCharacter::APlayerCharacter()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
Camera = CreateDefaultSubobject<UCameraComponent>("Camera");
Camera->SetupAttachment(RootComponent);
Camera->bUsePawnControlRotation = true;
}
// Called when the game starts or when spawned
void APlayerCharacter::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APlayerCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
//Add Input Mapping Context
if (APlayerController* PlayerController = Cast<APlayerController>(Controller))
{
//Get Local Player Subsystem
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
{
Subsystem->AddMappingContext(InputMapping, 0);
}
}
if (UEnhancedInputComponent* Input = CastChecked<UEnhancedInputComponent>(PlayerInputComponent))
{
Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &APlayerCharacter::Move);
Input->BindAction(LookAction, ETriggerEvent::Triggered, this, &APlayerCharacter::Look);
Input->BindAction(JumpAction, ETriggerEvent::Triggered, this, &APlayerCharacter::Jump);
}
}
void APlayerCharacter::Move(const FInputActionValue& InputValue)
{
FVector2D InputVector = InputValue.Get<FVector2D>();
if (IsValid(Controller))
{
//Get Forward Direction
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
//Add Movement Input
AddMovementInput(ForwardDirection, InputVector.Y);
AddMovementInput(RightDirection, InputVector.X);
}
}
void APlayerCharacter::Look(const FInputActionValue& InputValue)
{
FVector2D InputVector = InputValue.Get<FVector2D>();
if (IsValid(Controller))
{
AddControllerYawInput(InputVector.X);
AddControllerPitchInput(InputVector.Y);
}
}
void APlayerCharacter::Jump()
{
ACharacter::Jump();
}