44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "Player/LMPlayerController.h"
|
|
#include "EnhancedInputSubsystems.h"
|
|
#include "EnhancedInputComponent.h"
|
|
#include "GameFramework/Character.h"
|
|
#include "Player/LMPlayer.h"
|
|
|
|
void ALMPlayerController::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
EnhancedInputSubsystem = GetLocalPlayer()->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>();
|
|
EnhancedInputSubsystem->AddMappingContext(DefaultMappingContext, 0);
|
|
LegumixPlayer = Cast<ALMPlayer>(GetPawn());
|
|
}
|
|
|
|
void ALMPlayerController::SetupInputComponent()
|
|
{
|
|
Super::SetupInputComponent();
|
|
UEnhancedInputComponent* Input = Cast<UEnhancedInputComponent>(InputComponent);
|
|
Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Move);
|
|
Input->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Jump);
|
|
Input->BindAction(LookAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Look);
|
|
}
|
|
|
|
void ALMPlayerController::Move(const FInputActionValue& InputValue)
|
|
{
|
|
const FVector2d VectorDirection = InputValue.Get<FVector2d>();
|
|
GetPawn()->AddMovementInput(GetPawn()->GetActorForwardVector(), VectorDirection.X);
|
|
GetPawn()->AddMovementInput(GetPawn()->GetActorRightVector(), VectorDirection.Y);
|
|
}
|
|
|
|
void ALMPlayerController::Jump(const FInputActionValue& InputValue)
|
|
{
|
|
LegumixPlayer->Jump();
|
|
}
|
|
|
|
void ALMPlayerController::Look(const FInputActionValue& InputValue)
|
|
{
|
|
const FVector2d VectorDirection = InputValue.Get<FVector2d>();
|
|
AddYawInput(VectorDirection.X);
|
|
AddPitchInput(VectorDirection.Y);
|
|
} |