From 8b87098cf8e3160d15abbe1f0d544d37ae092c4b Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Sun, 21 May 2023 19:06:16 +0100 Subject: [PATCH] Updated Book & Gun to be Pickupable by Interact Key --- Content/Assets/Gun/SM_MERGED_Gun_Book.uasset | 4 ++-- .../Gun/SM_MERGED_Gun_Book_Blueprint.uasset | 4 ++-- Content/Levels/Build.umap | 2 +- .../PlayerTemp/TempCharacter.cpp | 23 ++++++++++++------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Content/Assets/Gun/SM_MERGED_Gun_Book.uasset b/Content/Assets/Gun/SM_MERGED_Gun_Book.uasset index e1a7da2..d70e5b1 100644 --- a/Content/Assets/Gun/SM_MERGED_Gun_Book.uasset +++ b/Content/Assets/Gun/SM_MERGED_Gun_Book.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:31724d37643af92724f5cd94cc3a2b174144d6b1b2798c612fdb293a8464e95f -size 210301 +oid sha256:0df0495f5eb102c8b4a820a4b875b14a2c97dd3dd561286560650514af974296 +size 208256 diff --git a/Content/Assets/Gun/SM_MERGED_Gun_Book_Blueprint.uasset b/Content/Assets/Gun/SM_MERGED_Gun_Book_Blueprint.uasset index 4b4324c..e8c3066 100644 --- a/Content/Assets/Gun/SM_MERGED_Gun_Book_Blueprint.uasset +++ b/Content/Assets/Gun/SM_MERGED_Gun_Book_Blueprint.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dc8146c9873e4a49c9575bb30d02a620984283cc50240fb7b445842f43677f25 -size 71513 +oid sha256:1a9fcd335f5abb64ef1608e14098933241b7fb0640566b7b82c654cffe5ef66d +size 95019 diff --git a/Content/Levels/Build.umap b/Content/Levels/Build.umap index c3637fa..aed57bb 100644 --- a/Content/Levels/Build.umap +++ b/Content/Levels/Build.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:347472e4d649421771f9ef7422945b20c998b4537db9aaafc2963b398dd52015 +oid sha256:2cc367430bcb245184dea24af72599b607ae2c8ab62ce5bc958d127251350baf size 5623699 diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 211deb3..54b0630 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -11,6 +11,7 @@ #include "Components/PawnNoiseEmitterComponent.h" #include "Blueprint/WidgetBlueprintLibrary.h" #include "Kismet/KismetMathLibrary.h" +#include "Misc/OutputDeviceNull.h" // CONSTRUCTOR @@ -130,7 +131,8 @@ void ATempCharacter::Tick(float DeltaTime) } if (OutResult.GetActor()->ActorHasTag("Probertium") || OutResult.GetActor()->ActorHasTag("Iroquid") || OutResult.GetActor()->ActorHasTag("Azos") || OutResult.GetActor()->ActorHasTag("Eis") - || OutResult.GetActor()->ActorHasTag("NPC") || OutResult.GetActor()->FindComponentByClass()) + || OutResult.GetActor()->ActorHasTag("NPC") || OutResult.GetActor()->ActorHasTag("Interactable") + || OutResult.GetActor()->FindComponentByClass()) { CrossHair->SetBrush(UWidgetBlueprintLibrary::MakeBrushFromTexture(InteractableCrossHair)); CrossHair->SetDesiredSizeOverride(FVector2D(43.6, 51.3)); @@ -173,9 +175,9 @@ void ATempCharacter::LineTraceLogic() { //UE_LOG(LogTemp, Display, TEXT("LineTraceLogic activated")); ThisCamera = Cast(this->FindComponentByClass()); - float GlobalTrace = TraceDistance; - FVector Start = ThisCamera->GetComponentLocation(); - FVector End = Start + GlobalTrace * ThisCamera->GetForwardVector(); + const float GlobalTrace = TraceDistance; + const FVector Start = ThisCamera->GetComponentLocation(); + const FVector End = Start + GlobalTrace * ThisCamera->GetForwardVector(); FCollisionQueryParams TraceParams; TraceParams.AddIgnoredActor(this); bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Pawn, TraceParams); @@ -205,10 +207,17 @@ void ATempCharacter::LineTraceLogic() AddToInventory(); return; } + if (OutHit.GetActor()->ActorHasTag(TEXT("Interactable"))) + { + FOutputDeviceNull AR; + const FString Command = FString::Printf(TEXT("Interact")); + OutHit.GetActor()->CallFunctionByNameWithArguments(*Command, AR, nullptr, true); + return; + } if (OutHit.GetActor()->FindComponentByClass()) { UE_LOG(LogTemp, Display, TEXT("Hit Merchant")); - auto ItemArray = OutHit.GetActor()->FindComponentByClass()->GetItem(0); + const auto ItemArray = OutHit.GetActor()->FindComponentByClass()->GetItem(0); if (GoldBalance >= ItemArray->ItemCostPrice) { GoldBalance -= ItemArray->ItemCostPrice; @@ -238,7 +247,7 @@ void ATempCharacter::AddToInventory() if (OutHit.GetActor()->FindComponentByClass()) { UE_LOG(LogTemp, Display, TEXT("Hit Merchant")); - auto ItemArray = OutHit.GetActor()->FindComponentByClass()->GetItem(0); + const auto ItemArray = OutHit.GetActor()->FindComponentByClass()->GetItem(0); if (GoldBalance >= ItemArray->ItemCostPrice) { GoldBalance -= ItemArray->ItemCostPrice; @@ -255,8 +264,6 @@ void ATempCharacter::AddToInventory() void ATempCharacter::InputDisabler() { - //TURNING OFF CROSSHAIR - CrossHairWidget->SetVisibility(ESlateVisibility::Hidden); //Set to UI Mode Only