Updated TempCharacter to start fixing bugs

This commit is contained in:
MarcelHara 2023-05-09 16:22:35 +01:00
parent b0e9ad546b
commit fc25c8adf0
5 changed files with 24 additions and 15 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -142,18 +142,31 @@ void ATempCharacter::LineTraceLogic()
FVector End = Start + GlobalTrace * ThisCamera->GetForwardVector(); 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);
if (bHit) if (bHit)
{ {
//we store the GetItem function from InventoryComponent into ItemArray variable
if (OutHit.GetActor() == nullptr) if (OutHit.GetActor() == nullptr)
{ {
return; return;
} }
if (OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()) if (OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
{ {
if(OutHit.GetActor()->ActorHasTag(TEXT("Probertium")))
{
OutHit.GetActor()->Destroy();
}
else if(OutHit.GetActor()->ActorHasTag(TEXT("Iroquid")))
{
OutHit.GetActor()->Destroy();
}
else if (OutHit.GetActor()->ActorHasTag(TEXT("Azos")))
{
OutHit.GetActor()->Destroy();
}
else if (OutHit.GetActor()->ActorHasTag(TEXT("Eis")))
{
OutHit.GetActor()->Destroy();
}
UE_LOG(LogTemp, Display, TEXT("Hit Merchant")); UE_LOG(LogTemp, Display, TEXT("Hit Merchant"));
auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0); auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0);
if (GoldBalance >= ItemArray->ItemCostPrice) if (GoldBalance >= ItemArray->ItemCostPrice)
@ -166,10 +179,6 @@ void ATempCharacter::LineTraceLogic()
{ {
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold")); UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));
} }
if (OutHit.GetActor()->ActorHasTag(Ammo))
{
OutHit.GetActor()->Destroy();
}
} }
// if the actor hit has the interaction component/script then it will activate the code // if the actor hit has the interaction component/script then it will activate the code