Updated Book & Gun to be Pickupable by Interact Key
This commit is contained in:
parent
d17ba9e064
commit
8b87098cf8
BIN
Content/Assets/Gun/SM_MERGED_Gun_Book.uasset
(Stored with Git LFS)
BIN
Content/Assets/Gun/SM_MERGED_Gun_Book.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Assets/Gun/SM_MERGED_Gun_Book_Blueprint.uasset
(Stored with Git LFS)
BIN
Content/Assets/Gun/SM_MERGED_Gun_Book_Blueprint.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/Build.umap
(Stored with Git LFS)
BIN
Content/Levels/Build.umap
(Stored with Git LFS)
Binary file not shown.
@ -11,6 +11,7 @@
|
|||||||
#include "Components/PawnNoiseEmitterComponent.h"
|
#include "Components/PawnNoiseEmitterComponent.h"
|
||||||
#include "Blueprint/WidgetBlueprintLibrary.h"
|
#include "Blueprint/WidgetBlueprintLibrary.h"
|
||||||
#include "Kismet/KismetMathLibrary.h"
|
#include "Kismet/KismetMathLibrary.h"
|
||||||
|
#include "Misc/OutputDeviceNull.h"
|
||||||
|
|
||||||
|
|
||||||
// CONSTRUCTOR
|
// CONSTRUCTOR
|
||||||
@ -130,7 +131,8 @@ void ATempCharacter::Tick(float DeltaTime)
|
|||||||
}
|
}
|
||||||
if (OutResult.GetActor()->ActorHasTag("Probertium") || OutResult.GetActor()->ActorHasTag("Iroquid")
|
if (OutResult.GetActor()->ActorHasTag("Probertium") || OutResult.GetActor()->ActorHasTag("Iroquid")
|
||||||
|| OutResult.GetActor()->ActorHasTag("Azos") || OutResult.GetActor()->ActorHasTag("Eis")
|
|| OutResult.GetActor()->ActorHasTag("Azos") || OutResult.GetActor()->ActorHasTag("Eis")
|
||||||
|| OutResult.GetActor()->ActorHasTag("NPC") || OutResult.GetActor()->FindComponentByClass<UInventoryComponent>())
|
|| OutResult.GetActor()->ActorHasTag("NPC") || OutResult.GetActor()->ActorHasTag("Interactable")
|
||||||
|
|| OutResult.GetActor()->FindComponentByClass<UInventoryComponent>())
|
||||||
{
|
{
|
||||||
CrossHair->SetBrush(UWidgetBlueprintLibrary::MakeBrushFromTexture(InteractableCrossHair));
|
CrossHair->SetBrush(UWidgetBlueprintLibrary::MakeBrushFromTexture(InteractableCrossHair));
|
||||||
CrossHair->SetDesiredSizeOverride(FVector2D(43.6, 51.3));
|
CrossHair->SetDesiredSizeOverride(FVector2D(43.6, 51.3));
|
||||||
@ -173,9 +175,9 @@ void ATempCharacter::LineTraceLogic()
|
|||||||
{
|
{
|
||||||
//UE_LOG(LogTemp, Display, TEXT("LineTraceLogic activated"));
|
//UE_LOG(LogTemp, Display, TEXT("LineTraceLogic activated"));
|
||||||
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
||||||
float GlobalTrace = TraceDistance;
|
const float GlobalTrace = TraceDistance;
|
||||||
FVector Start = ThisCamera->GetComponentLocation();
|
const FVector Start = ThisCamera->GetComponentLocation();
|
||||||
FVector End = Start + GlobalTrace * ThisCamera->GetForwardVector();
|
const FVector End = Start + GlobalTrace * ThisCamera->GetForwardVector();
|
||||||
FCollisionQueryParams TraceParams;
|
FCollisionQueryParams TraceParams;
|
||||||
TraceParams.AddIgnoredActor(this);
|
TraceParams.AddIgnoredActor(this);
|
||||||
bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Pawn, TraceParams);
|
bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Pawn, TraceParams);
|
||||||
@ -205,10 +207,17 @@ void ATempCharacter::LineTraceLogic()
|
|||||||
AddToInventory();
|
AddToInventory();
|
||||||
return;
|
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<UInventoryComponent>())
|
if (OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Display, TEXT("Hit Merchant"));
|
UE_LOG(LogTemp, Display, TEXT("Hit Merchant"));
|
||||||
auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0);
|
const auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0);
|
||||||
if (GoldBalance >= ItemArray->ItemCostPrice)
|
if (GoldBalance >= ItemArray->ItemCostPrice)
|
||||||
{
|
{
|
||||||
GoldBalance -= ItemArray->ItemCostPrice;
|
GoldBalance -= ItemArray->ItemCostPrice;
|
||||||
@ -238,7 +247,7 @@ void ATempCharacter::AddToInventory()
|
|||||||
if (OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
|
if (OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Display, TEXT("Hit Merchant"));
|
UE_LOG(LogTemp, Display, TEXT("Hit Merchant"));
|
||||||
auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0);
|
const auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0);
|
||||||
if (GoldBalance >= ItemArray->ItemCostPrice)
|
if (GoldBalance >= ItemArray->ItemCostPrice)
|
||||||
{
|
{
|
||||||
GoldBalance -= ItemArray->ItemCostPrice;
|
GoldBalance -= ItemArray->ItemCostPrice;
|
||||||
@ -255,8 +264,6 @@ void ATempCharacter::AddToInventory()
|
|||||||
|
|
||||||
void ATempCharacter::InputDisabler()
|
void ATempCharacter::InputDisabler()
|
||||||
{
|
{
|
||||||
//TURNING OFF CROSSHAIR
|
|
||||||
|
|
||||||
CrossHairWidget->SetVisibility(ESlateVisibility::Hidden);
|
CrossHairWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||||
|
|
||||||
//Set to UI Mode Only
|
//Set to UI Mode Only
|
||||||
|
Loading…
Reference in New Issue
Block a user