Implemented Input for Interacting
This commit is contained in:
parent
be22eae329
commit
64420326c0
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:d9d96d19206de2c336790632a9774519478154bb0eedd7080b8ee8c485e15844
|
oid sha256:b32ceb2fef229808e1ce4cb7ed0542b84e6e0b0e6b93e7a6d0bcd7bdeea57895
|
||||||
size 43857
|
size 18290
|
||||||
|
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Interact.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Interact.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Input/IMC_Default.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Input/IMC_Default.uasset
(Stored with Git LFS)
Binary file not shown.
@ -6,6 +6,7 @@
|
|||||||
#include "Components/CapsuleComponent.h"
|
#include "Components/CapsuleComponent.h"
|
||||||
#include "EnhancedInputComponent.h"
|
#include "EnhancedInputComponent.h"
|
||||||
#include "EnhancedInputSubsystems.h"
|
#include "EnhancedInputSubsystems.h"
|
||||||
|
#include "InteractableActor.h"
|
||||||
#include "AI/EnemyCharacter.h"
|
#include "AI/EnemyCharacter.h"
|
||||||
#include "GameFramework/CharacterMovementComponent.h"
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
@ -102,9 +103,31 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
|
|||||||
//Crouching
|
//Crouching
|
||||||
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::SetCrouch);
|
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::SetCrouch);
|
||||||
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::SetUnCrouch);
|
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::SetUnCrouch);
|
||||||
|
|
||||||
|
//Interacting
|
||||||
|
EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::Interact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::Interact()
|
||||||
|
{
|
||||||
|
FHitResult OutHit;
|
||||||
|
FCollisionQueryParams QueryParams = FCollisionQueryParams::DefaultQueryParam;
|
||||||
|
QueryParams.AddIgnoredActor(this);
|
||||||
|
FVector LT_Start = FirstPersonCameraComponent->GetComponentLocation();
|
||||||
|
FVector LT_End = LT_Start + (FirstPersonCameraComponent->GetForwardVector() * InteractionRange);
|
||||||
|
DrawDebugLine(GetWorld(), LT_Start, LT_End, FColor::Red, false, 3, 0, 2);
|
||||||
|
if (!GetWorld()->LineTraceSingleByChannel(OutHit, LT_Start, LT_End, ECC_Camera, QueryParams)) return;
|
||||||
|
|
||||||
|
AActor* HitActor = OutHit.GetActor();
|
||||||
|
AInteractableActor* InteractableActor = Cast<AInteractableActor>(HitActor);
|
||||||
|
if (!IsValid(InteractableActor)) return;
|
||||||
|
|
||||||
|
DrawDebugLine(GetWorld(), LT_Start, OutHit.ImpactPoint, FColor::Green, false, 3, 0, 2);
|
||||||
|
InteractableActor->Interact();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::SetCrouch()
|
void AEndlessVendettaCharacter::SetCrouch()
|
||||||
{
|
{
|
||||||
Crouch();
|
Crouch();
|
||||||
|
@ -68,6 +68,9 @@ class AEndlessVendettaCharacter : public ACharacter
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||||
UInputAction* CrouchAction;
|
UInputAction* CrouchAction;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||||
|
UInputAction* InteractAction;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AEndlessVendettaCharacter();
|
AEndlessVendettaCharacter();
|
||||||
|
|
||||||
@ -146,6 +149,9 @@ protected:
|
|||||||
void EquipPrimary();
|
void EquipPrimary();
|
||||||
void EquipSecondary();
|
void EquipSecondary();
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category = "Interaction")
|
||||||
|
float InteractionRange = 250;
|
||||||
|
void Interact();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// APawn interface
|
// APawn interface
|
||||||
|
Loading…
Reference in New Issue
Block a user