LineTrace works and is detecting objects.
LineTrace works and is detecting objects from the player using the interact button. Also cleaned up some scripts and deleted unused MerchantTriggerBox script.
This commit is contained in:
parent
ca90d5fc6e
commit
8ee792226c
BIN
Content/Levels/Main.umap
(Stored with Git LFS)
BIN
Content/Levels/Main.umap
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/MerchantPrototype.umap
(Stored with Git LFS)
BIN
Content/Levels/MerchantPrototype.umap
(Stored with Git LFS)
Binary file not shown.
@ -1,32 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "MerchantTriggerBox.h"
|
||||
|
||||
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
|
||||
|
||||
//makes it so the component script is initialized when game starts
|
||||
UMerchantTriggerBox::UMerchantTriggerBox()
|
||||
{
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void UMerchantTriggerBox::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
UE_LOG(LogTemp, Warning, TEXT("TRIGGER SPAWNED"));
|
||||
}
|
||||
|
||||
|
||||
void UMerchantTriggerBox::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,23 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Components/PrimitiveComponent.h"
|
||||
#include "MerchantTriggerBox.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||
class THE_TWILIGHT_ABYSS_API UMerchantTriggerBox : public UBoxComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
UMerchantTriggerBox();
|
||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
};
|
@ -58,34 +58,27 @@ void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo
|
||||
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(FKey Interact)
|
||||
void ATempCharacter::KeyPressed()
|
||||
{
|
||||
//vars for LineTraceSingleByChannel
|
||||
TraceDistance = 1000;
|
||||
FHitResult Hit;
|
||||
FRotator Rot;
|
||||
FVector Location;
|
||||
FVector Start = Location;
|
||||
FVector End = Start + (Rot.Vector() * TraceDistance);
|
||||
|
||||
GetController()->GetPlayerViewPoint(Location, Rot); // where the player is looking thats what we set the location/rotation too
|
||||
FVector Start = GetActorLocation();
|
||||
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());
|
||||
//Hit.GetActor()->Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("BHIT IS FALSE"));
|
||||
}
|
||||
|
||||
/*
|
||||
TODO:
|
||||
FIX IT SO THE TRACE IS NOT HITTING PLANE
|
||||
ITS HITTING PLANE NO MATTER WHAT MAYBE FIX LOCATION OF WHERE ITS BEING SHOT FROM?
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,5 @@ public:
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
void KeyPressed(FKey Interact);
|
||||
|
||||
|
||||
void KeyPressed();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user