diff --git a/Content/Blueprints/Player/BP_MyTempCharacter.uasset b/Content/Blueprints/Player/BP_MyTempCharacter.uasset index 6d29306..eade3bb 100644 --- a/Content/Blueprints/Player/BP_MyTempCharacter.uasset +++ b/Content/Blueprints/Player/BP_MyTempCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:332683390d0d3643a2a4d23fead25244edc382a04ffc2938fe192e57d6311ea7 -size 50935 +oid sha256:f75c1a60b8b5ff0cfd87d50b69761c177d42897fe5881e3b2348ffe93964100e +size 50991 diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index eae1761..ad5e537 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -77,16 +77,18 @@ void ATempCharacter::LineTraceLogic() bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Visibility, TraceParams); if (bHit) { + //we store the GetItem function from InventoryComponent into ItemArray variable + auto ItemArray = OutHit.GetActor()->FindComponentByClass()->GetItem(0); if(OutHit.GetActor() == nullptr) { return; } if(OutHit.GetActor()->FindComponentByClass()) { - if(GoldBalance >= OutHit.GetActor()->FindComponentByClass()->GetItem(0)->ItemCostPrice) + if(GoldBalance >= ItemArray->ItemCostPrice) { - GoldBalance -= OutHit.GetActor()->FindComponentByClass()->GetItem(0)->ItemCostPrice; - Inventory->AddItem(OutHit.GetActor()->FindComponentByClass()->GetItem(0)); + GoldBalance -= ItemArray->ItemCostPrice; + Inventory->AddItem(ItemArray); UE_LOG(LogTemp, Display, TEXT("Item Purchased")); } if(GoldBalance <= 0)