Hi, I want to break struct to set its properties, I hope you have experience with that and can help me.
Blueprint version.
I am stuck here.
for (int32 i = 1; i <= WeaponItemDatas.ProbabalityPercent; i++)
{
Arr.Add(/*Here I am stuck, how to break struct and set its properties*/);
}
Thereâs no âbreak structâ for C++, thatâs a BP convention. You simply need to create an instance of your struct and populate the valuesâŚsomething like this
FST_ItemTypeAndID TmpItem;
for (int32 i = 1; i <= WeaponItemDatas.ProbabalityPercent; i++)
{
TmpItem.Type = blah;
TmpItem.ID = blah;
Arr.Add(TmpItem);
}
Of course I donât know if youâre using proper naming conventions but your struct should have an âFâ at the beginning like I have it in the example aboveâŚand of course replace the blahâs with actual values 
2 Likes
Thank you sir very very much for this perfect and easy solution , I really appreciate 
I followed your answer and it works fine for now and compiles.
for (int32 i = 1; i <= WeaponItemDatas.ProbabalityPercent; i++)
{
TempItemTypeAndID_var.ID = Array;
TempItemTypeAndID_var.Type = EItemType::E_Weapon;
Arr.Add(TempItemTypeAndID_var);
}
I would like to confirm that I am setting the Type
correctly grabbing from enum
?
TempItemTypeAndID_var.Type = EItemType::E_Weapon;
This page can help:
https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/DevelopmentSetup/CodingStandard/
It will be better if instead of naming Type you name it as WeaponType, something more specific.
1 Like
yes in case if I have one type of item but I have them many and the variable TempItemTypeAndID_var
is used to set ID and Type for each of them.

Yes, that is indeed the correct way to assign an enum
1 Like