20 PrimaryActorTick.bCanEverTick =
true;
23 ConstructorHelpers::FObjectFinder<UInputMappingContext> imcRef(TEXT(
"/Script/EnhancedInput.InputMappingContext'/Game/CustomContents/Input/Player/IMC_Robot.IMC_Robot'"));
24 if (imcRef.Succeeded())
29 ConstructorHelpers::FObjectFinder<UInputAction> moveActionRef(TEXT(
"/Script/EnhancedInput.InputAction'/Game/CustomContents/Input/Player/IA_RobotMove.IA_RobotMove'"));
30 if (moveActionRef.Succeeded())
35 ConstructorHelpers::FObjectFinder<UInputAction> lookActionRef(TEXT(
"/Script/EnhancedInput.InputAction'/Game/CustomContents/Input/Player/IA_RobotLook.IA_RobotLook'"));
36 if (lookActionRef.Succeeded())
41 ConstructorHelpers::FObjectFinder<UInputAction> jumpActionRef(TEXT(
"/Script/EnhancedInput.InputAction'/Game/CustomContents/Input/Player/IA_RobotJump.IA_RobotJump'"));
42 if (jumpActionRef.Succeeded())
47 ConstructorHelpers::FObjectFinder<UInputAction> runActionRef(TEXT(
"/Script/EnhancedInput.InputAction'/Game/CustomContents/Input/Player/IA_RobotRun.IA_RobotRun'"));
48 if (runActionRef.Succeeded())
53 ConstructorHelpers::FObjectFinder<UInputAction> interactActionRef(TEXT(
"/Script/EnhancedInput.InputAction'/Game/CustomContents/Input/Player/IA_RobotInteract.IA_RobotInteract'"));
54 if (interactActionRef.Succeeded())
66 ConstructorHelpers::FObjectFinder<USkeletalMesh> playerMeshRef(TEXT(
"/Script/Engine.SkeletalMesh'/Game/CustomContents/Character/Asset/Owl/SKM_GreenOwlRobot.SKM_GreenOwlRobot'"));
67 if (playerMeshRef.Succeeded())
69 GetMesh()->SetSkeletalMesh(playerMeshRef.Object);
70 GetMesh()->SetRelativeLocationAndRotation(FVector(0, 0, -70), FRotator(0, -90, 0));
75 ConstructorHelpers::FClassFinder<UAnimInstance> playerABPRef(TEXT(
"/Game/CustomContents/Animations/ABP_Owl.ABP_Owl_C"));
76 if (playerABPRef.Succeeded())
78 GetMesh()->SetAnimInstanceClass(playerABPRef.Class);
82 GetCapsuleComponent()->InitCapsuleSize(35.f, 70.0f);
85 bUseControllerRotationPitch =
false;
86 bUseControllerRotationYaw =
true;
87 bUseControllerRotationRoll =
false;
89 GetCharacterMovement()->RotationRate = FRotator(0.0f, 500.0f, 0.0f);
90 GetCharacterMovement()->MaxWalkSpeed =
WalkSpeed;
91 GetCharacterMovement()->bOrientRotationToMovement =
true;
94 InteractionSystem = CreateDefaultSubobject<UInteractionSystem>(TEXT(
"InteractionSystem"));
97 HoldPosition = CreateDefaultSubobject<USceneComponent>(TEXT(
"HoldPosition"));
101 CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT(
"CameraBoom"));
106 FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT(
"FollowCamera"));
109 FollowCamera->SetRelativeLocationAndRotation(FVector(0,-14.285715,21.428572), FRotator(90, 90, 0));
135 Super::SetupPlayerInputComponent(PlayerInputComponent);
137 auto playerInput = Cast<UEnhancedInputComponent>(PlayerInputComponent);
154 FVector2D MovementVector = Value.Get<FVector2D>();
156 if (GetController() !=
nullptr)
159 const FRotator Rotation = GetController()->GetControlRotation();
160 const FRotator YawRotation(0, Rotation.Yaw, 0);
163 const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
166 const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
169 AddMovementInput(ForwardDirection, MovementVector.Y);
170 AddMovementInput(RightDirection, MovementVector.X);