From 8ee792226c0841643e1481da025d5b07cb3c7351 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Fri, 11 Nov 2022 20:21:44 +0000 Subject: [PATCH] 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. --- Content/Levels/Main.umap | 4 +-- Content/Levels/MerchantPrototype.umap | 4 +-- .../MerchantRaw/MerchantTriggerBox.cpp | 32 ------------------- .../MerchantRaw/MerchantTriggerBox.h | 23 ------------- .../PlayerTemp/TempCharacter.cpp | 21 ++++-------- .../PlayerTemp/TempCharacter.h | 4 +-- 6 files changed, 12 insertions(+), 76 deletions(-) delete mode 100644 Source/the_twilight_abyss/MerchantRaw/MerchantTriggerBox.cpp delete mode 100644 Source/the_twilight_abyss/MerchantRaw/MerchantTriggerBox.h diff --git a/Content/Levels/Main.umap b/Content/Levels/Main.umap index 41d596c..c222134 100644 --- a/Content/Levels/Main.umap +++ b/Content/Levels/Main.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ebb3f05b577a887b28ac85a9ddaa08e24356d99ac9d62c3104fee7d581ad2295 -size 59332 +oid sha256:6bebf971694ff133b986b1161ef8fe37e829e7c2d709da17a7be9444ea35a6c0 +size 57923 diff --git a/Content/Levels/MerchantPrototype.umap b/Content/Levels/MerchantPrototype.umap index fcd37b4..abef8df 100644 --- a/Content/Levels/MerchantPrototype.umap +++ b/Content/Levels/MerchantPrototype.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:778b88f378fa880bd4f070863d6d6e2f130571b7c07d93a3aae4c4679a44a6bc -size 24169 +oid sha256:71972a686580a51b5e39734fdadcbead9cab44f70aa423b1c2e684eb5c64d855 +size 23271 diff --git a/Source/the_twilight_abyss/MerchantRaw/MerchantTriggerBox.cpp b/Source/the_twilight_abyss/MerchantRaw/MerchantTriggerBox.cpp deleted file mode 100644 index 79ebc12..0000000 --- a/Source/the_twilight_abyss/MerchantRaw/MerchantTriggerBox.cpp +++ /dev/null @@ -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); - - -} - - - - diff --git a/Source/the_twilight_abyss/MerchantRaw/MerchantTriggerBox.h b/Source/the_twilight_abyss/MerchantRaw/MerchantTriggerBox.h deleted file mode 100644 index 980a86e..0000000 --- a/Source/the_twilight_abyss/MerchantRaw/MerchantTriggerBox.h +++ /dev/null @@ -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; -}; diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 63a9a08..d3affc5 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -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); + FVector Start = GetActorLocation(); + FVector End = Start + TraceDistance * GetActorForwardVector(); - GetController()->GetPlayerViewPoint(Location, Rot); // where the player is looking thats what we set the location/rotation too - 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? - */ } + diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index c492c53..f5df595 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -33,7 +33,5 @@ public: // Called to bind functionality to input virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; - void KeyPressed(FKey Interact); - - + void KeyPressed(); };