problem solved, no idea why

This commit is contained in:
2025-11-22 16:28:39 -05:00
parent a59399ebfe
commit bb0d0a8660
8 changed files with 91 additions and 20 deletions

View File

@@ -2,11 +2,15 @@
#include "DDIPlayerController.h"
#include "DDICharacter.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
#include "Engine/LocalPlayer.h"
#include "InputMappingContext.h"
#include "GameFramework/Character.h"
ADDIPlayerController::ADDIPlayerController()
{
}
void ADDIPlayerController::BeginPlay()
{
@@ -24,7 +28,18 @@ void ADDIPlayerController::BeginPlay()
void ADDIPlayerController::SetupInputComponent()
{
// Super::SetupInputComponent();
Super::SetupInputComponent();
if (UEnhancedInputComponent* Subsystem = Cast<UEnhancedInputComponent>(InputComponent))
{
if (MoveAction) Subsystem->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ADDIPlayerController::Move);
if (LookAction) Subsystem->BindAction(LookAction, ETriggerEvent::Triggered, this, &ADDIPlayerController::Look);
if (JumpAction)
{
Subsystem->BindAction(JumpAction, ETriggerEvent::Started, this, &ADDIPlayerController::Jump);
Subsystem->BindAction(JumpAction, ETriggerEvent::Completed, this, &ADDIPlayerController::JumpEnd);
}
}
}
void ADDIPlayerController::OnPossess(APawn* InPawn)
@@ -32,9 +47,54 @@ void ADDIPlayerController::OnPossess(APawn* InPawn)
Super::OnPossess(InPawn);
// is this a shooter character?
if (ADDICharacter* DDICharacter = Cast<ADDICharacter>(InPawn))
// if (ADDICharacter* DDICharacter = Cast<ADDICharacter>(InPawn))
// {
// // add the player tag
// DDICharacter->Tags.Add(PlayerPawnTag);
// }
}
void ADDIPlayerController::Move(const FInputActionValue& Value)
{
const FVector2D MovementVector = Value.Get<FVector2D>();
if (APawn* ControlledPawn = GetPawn())
{
// add the player tag
DDICharacter->Tags.Add(PlayerPawnTag);
FRotator CameraRotation = GetControlRotation();
FRotator YawRotation(0.f, CameraRotation.Yaw, 0.f);
FVector ForwardDiection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
ControlledPawn->AddMovementInput(ForwardDiection, MovementVector.Y);
ControlledPawn->AddMovementInput(RightDirection,MovementVector.X);
}
}
void ADDIPlayerController::Look(const FInputActionValue& Value)
{
const FVector2D LookAxisVector = Value.Get<FVector2D>();
if (APawn* ControlledPawn = GetPawn())
{
AddYawInput(LookAxisVector.X);
AddPitchInput(LookAxisVector.Y);
}
}
void ADDIPlayerController::Jump(const FInputActionValue& Value)
{
if (ACharacter* character = GetCharacter())
{
character->Jump();
}
}
void ADDIPlayerController::JumpEnd(const FInputActionValue& Value)
{
if (ACharacter* character = GetCharacter())
{
character->StopJumping();
}
}