Lesson 105 - Set up move to click.

This commit is contained in:
2025-10-16 14:33:58 -04:00
parent 99439dcee7
commit d436c459ec
108 changed files with 11025 additions and 21587 deletions

View File

@@ -1,14 +1,21 @@
// Copyright Echo Devgroup
#include "AbilitySystemBlueprintLibrary.h"
#include "Player/AuraPlayerController.h"
#include "AuraGameplayTags.h"
#include "EnhancedInputSubsystems.h"
#include "EnhancedInputComponent.h"
#include "AbilitySystem/AuraAbilitySystemComponent.h"
#include "AbilitySystem/AuraAbilitySystemLibrary.h"
#include "Components/SplineComponent.h"
#include "Input/AuraInputComponent.h"
#include "Interact/EnemyInterface.h"
AAuraPlayerController::AAuraPlayerController()
{
bReplicates = true;
Spline = CreateDefaultSubobject<USplineComponent>("Spline");
}
void AAuraPlayerController::PlayerTick(float DeltaTime)
@@ -49,7 +56,7 @@ void AAuraPlayerController::CursorTrace()
if (ThisActor != nullptr)
{
//Case B
//ThisActor->HighlightActor();
ThisActor->HighlightActor();
//UE_LOG(LogTemp, Warning, TEXT("Case B"));
}
}
@@ -57,14 +64,14 @@ void AAuraPlayerController::CursorTrace()
{
if (ThisActor == nullptr)
{
//LastActor->UnHighlightActor();
LastActor->UnHighlightActor();
}
else
{
if (LastActor != ThisActor) // Case D
{
//LastActor->UnHighlightActor();
//ThisActor->HighlightActor();
LastActor->UnHighlightActor();
ThisActor->HighlightActor();
}
}
@@ -72,6 +79,74 @@ void AAuraPlayerController::CursorTrace()
}
void AAuraPlayerController::AbilityInputTagPressed(FGameplayTag InputTag)
{
//For Debug of key pressed
//GEngine->AddOnScreenDebugMessage(1, 3.f, FColor::Red, *InputTag.ToString());
//Are we targetting something?
if (InputTag.MatchesTagExact(FAuraGameplayTags::Get().Input_InputTag_LMB))
{
bTargeting = ThisActor ? true : false;
bAutoRunning = false;
}
}
void AAuraPlayerController::AbilityInputTagReleased(FGameplayTag InputTag)
{
//For Debug of Key Held
//GEngine->AddOnScreenDebugMessage(1, 3.f, FColor::Red, *InputTag.ToString());
if (GetASC() == nullptr) return;
GetASC()->AbilityInputTagReleased(InputTag);
}
void AAuraPlayerController::AbilityInputTagHeld(FGameplayTag InputTag)
{
//For Debug of Key Held
//GEngine->AddOnScreenDebugMessage(1, 3.f, FColor::Red, *InputTag.ToString());
if (!InputTag.MatchesTagExact(FAuraGameplayTags::Get().Input_InputTag_LMB))
{
if (GetASC() == nullptr) return;
GetASC()->AbilityInputTagHeld(InputTag);
}
if (bTargeting)
{
if (GetASC())
{
GetASC()->AbilityInputTagHeld(InputTag);
}
}
else
{
FollowTime += GetWorld()->GetDeltaSeconds(); //Add delta seconds to FollowTime
FHitResult Hit;
if (GetHitResultUnderCursor(ECC_Visibility, false, Hit))
{
CachedDestination = Hit.Location;
}
if (APawn* ControlledPawn = GetPawn())
{
const FVector WorldDirection = (CachedDestination - ControlledPawn->GetActorLocation()).GetSafeNormal();
ControlledPawn->AddMovementInput(WorldDirection);
}
}
}
UAuraAbilitySystemComponent* AAuraPlayerController::GetASC()
{
if (AuraAbilitySystemComponent == nullptr)
{
AuraAbilitySystemComponent = Cast<UAuraAbilitySystemComponent>(UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(GetPawn<APawn>()));
}
return AuraAbilitySystemComponent;
}
/* //cheated and skipped ahead to try and fix error :(
void AAuraPlayerController::HightlightActor(AActor* Actor)
{
@@ -109,10 +184,10 @@ void AAuraPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(InputComponent);
UAuraInputComponent* AuraInputComponent = CastChecked<UAuraInputComponent>(InputComponent);
AuraInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AAuraPlayerController::Move);
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AAuraPlayerController::Move);
AuraInputComponent->BindAbilityActions(InputConfig, this, &ThisClass::AbilityInputTagPressed, &ThisClass::AbilityInputTagHeld, &ThisClass::AbilityInputTagHeld);
}
void AAuraPlayerController::Move(const FInputActionValue& InputActionValue)