Hi,
I have a USTRUCT that I have for a cart, the player can add new struct in a cart that is an array of struct but I can’t manage to change the value of a struct member in that array of struct.
In BP I know I add to use the Set Struct Member and Set Array Element to achieve this but I can’t find their equivalent in C++ and my following code does not update the value (the for loop and if statement are working though)
for(FCartSaleItem ItemPresent : PlayerCartItem)
{
if(ItemPresent.ObjectMainID==Item->ObjectMainID&&ItemPresent.ObjectCurrentSelectedColorCollectionID==Item->ObjectColorCollectionID[Item->CurrentSelectedColorID]&&ItemPresent.ObjectCurrentSelectedSizeCollectionID==Item->ObjectSizeCollectionID[Item->CurrentSelectedSizeID])
{
ItemPresent.ObjectQuantityInCart++;
UE_LOG(LogTemp,Warning,TEXT("Item is already present in the cart"));
return;
}
else
{
ItemToAddToCart.ObjectMainID=Item->ObjectMainID;
ItemToAddToCart.ObjectQuantityInCart=1;
ItemToAddToCart.ObjectCurrentSelectedColorCollectionID=Item->ObjectColorCollectionID[Item->CurrentSelectedColorID];
ItemToAddToCart.ObjectCurrentSelectedSizeCollectionID=Item->ObjectSizeCollectionID[Item->CurrentSelectedSizeID];
ItemToAddToCart.ObjectBrandID=Item->ObjectBrandID;
ItemToAddToCart.ObjectName=Item->ObjectName;
ItemToAddToCart.ObjectDescription=Item->ObjectDescription;
ItemToAddToCart.InventoryObjectType=Item->InventoryObjectType;
ItemToAddToCart.InspectionObjectType=Item->InspectionObjectType;
PlayerCartItem.Add(ItemToAddToCart);
}
}
Thanks in advance.