Interaction between player and merchant works.

This commit is contained in:
MH261677 2022-11-11 20:35:41 +00:00
parent 8ee792226c
commit 2c7a717617
3 changed files with 10 additions and 20 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:71972a686580a51b5e39734fdadcbead9cab44f70aa423b1c2e684eb5c64d855
size 23271
oid sha256:f4a37ec4a9d65f2b21c7e29d31fb9b9dd998e181aa264ca826aa1e6594da30ef
size 23329

View File

@ -18,14 +18,12 @@ ATempCharacter::ATempCharacter()
void ATempCharacter::BeginPlay()
{
Super::BeginPlay();
}
//Binds the input we made in the setup player component to the forward vector
void ATempCharacter::ForwardInput(float Axis)
{
AddMovementInput(GetActorForwardVector()* Axis);
}
//Binds the input we made in the setup player component to the right vector
@ -51,13 +49,6 @@ void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo
PlayerInputComponent->BindAxis(TEXT("Look Up / Down Mouse"), this, &ATempCharacter::AddControllerPitchInput);
PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed); // custom keybind Interact
}
/*
TODO:
Make custom bool for pressed interact in trigger
Make custom bool for when player enters the trigger its set to true
Make if statement if both flags are true then dilouge box pops up
*/
void ATempCharacter::KeyPressed()
{
//vars for LineTraceSingleByChannel
@ -67,18 +58,19 @@ void ATempCharacter::KeyPressed()
FVector End = Start + TraceDistance * GetActorForwardVector();
FCollisionQueryParams TraceParams;
TraceParams.AddIgnoredActor(this);
bool bHit = GetWorld()->LineTraceSingleByChannel(Hit,Start,End,ECC_Visibility, TraceParams);
if(bHit)
{
DrawDebugLine(GetWorld(),Start, End, FColor::Green, false, 1.0f);
UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *Hit.GetActor()->GetName());
}
else
{
UE_LOG(LogTemp, Display, TEXT("BHIT IS FALSE"));
if(Hit.GetActor()->ActorHasTag("MerchantTag"))
{
DrawDebugLine(GetWorld(),Start, End, FColor::Green, false, 1.0f);
UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *Hit.GetActor()->GetName());
}
}
}

View File

@ -3,8 +3,6 @@
#pragma once
#include "CoreMinimal.h"
#include "Engine/World.h"
#include "DrawDebugHelpers.h"
#include "GameFramework/Character.h"
#include "TempCharacter.generated.h"