In the example you presented, i think it's better to use "name" rather than "string"s. The reason is that comparing names is faster than strings, so if you've got a lot of variables in your map and need to one up, it can shave some time off... Not usually a huge issue, but just food for thought. Btw, I've always enjoyed your content and it's really helped me learn ue4. Just glad that I have something to give back.
Hey Ryan, great vid as always. Since map variables do not replicate, should I not use them at all for multiplayer? I had started to use them for my inventory system but soon realized they had this limitation. Seems a shame this one variable type doesn't replicate!
That's kinda lame. You could use two arrays, but I would make a custom struct called InventorySlot or something, and have a single array of that. That gives you the added benefit of being able to have more data like durability, etc. in addition to the name and amount. That gives you the added benefit of being able to add more data like durability, etc. in addition to the name and amount.
I was going to mention this but there is more to it. The issue is the orders in the indices for the double array is not maintained between users. Additionally, maps are a complete and utter bother to work with since you need to find either keys or values. Your best bet is a struct you can break into values and then make an array of structs for items. If you want to be even more efficient, you can make your inventory based on a string array with a decoder. XXXX-YYY-ZZ and then parse it based on a struct list to fetch the data instead of hardcoding it. More pro-design tips ;)
Stats/attributes/inventory array and a stats/attributes/inventory enum and since enums are basically arrays themselves, you can use their index on your array to SetElem. And arrays are easy to replicate. The added benefit is that you can easily make "magic items", like a boot that gives +5 dexterity, simply by having an array on clothing articles that stores a struct of Enum_Attrib and Value, like (Dexterity, 5) and you can automatically grab that attribute from your array and add to it. Or have an attribute of Dex_base, Dex_add and Dex_multi which is combined when a Dex_actual is needed and add to the Dex_add instead so the multiplication won't complicate it.
Realy good video but How do you need to organize some inventory system with different values between each object. for example, I am creating a Survival game in which each type of wood has different characteristics that are used for different things, or even with minerals with strength, toughness and etc. but a Struct can´t have different values in its columns. What would be a solution?
Is there a quick way to compare the exact content of two maps? like whether map1 = map2 without worrying about the order of their elements but only key-value pairs
Hey, not sure if you know this, but you can use "Set" instead of maps, to compare the exact contents. If you need to use maps, then unfortunately I don't think there is a way, not that I can see anyways.
In the example you presented, i think it's better to use "name" rather than "string"s. The reason is that comparing names is faster than strings, so if you've got a lot of variables in your map and need to one up, it can shave some time off...
Not usually a huge issue, but just food for thought.
Btw, I've always enjoyed your content and it's really helped me learn ue4. Just glad that I have something to give back.
I've always wondered if this is a better version of variable management, than just having a struct with variables individually listed.
Thanks for this video Ryan! I love when you have a video for exactly what i need.
Thank you!
Do you have an example of a struct inside the map?
Love the intro❤️👍
Using the bool node from "find" does the same thing as "contains".
Other than that, good vid for beginners.
Hello friend there is any way to learn more about Map Variables?
As usual, great tutorial! I did not know you could map structs! This will be very useful to make an elaborate inventory system :) tx!
Hey Ryan, great vid as always. Since map variables do not replicate, should I not use them at all for multiplayer? I had started to use them for my inventory system but soon realized they had this limitation. Seems a shame this one variable type doesn't replicate!
That's kinda lame. You could use two arrays, but I would make a custom struct called InventorySlot or something, and have a single array of that. That gives you the added benefit of being able to have more data like durability, etc. in addition to the name and amount. That gives you the added benefit of being able to add more data like durability, etc. in addition to the name and amount.
I was going to mention this but there is more to it. The issue is the orders in the indices for the double array is not maintained between users.
Additionally, maps are a complete and utter bother to work with since you need to find either keys or values.
Your best bet is a struct you can break into values and then make an array of structs for items.
If you want to be even more efficient, you can make your inventory based on a string array with a decoder.
XXXX-YYY-ZZ
and then parse it based on a struct list to fetch the data instead of hardcoding it.
More pro-design tips ;)
Like Phil said, use STRUCT not maps, I used it in some parts of my game and it was never worth it.
Stats/attributes/inventory array and a stats/attributes/inventory enum and since enums are basically arrays themselves, you can use their index on your array to SetElem. And arrays are easy to replicate. The added benefit is that you can easily make "magic items", like a boot that gives +5 dexterity, simply by having an array on clothing articles that stores a struct of Enum_Attrib and Value, like (Dexterity, 5) and you can automatically grab that attribute from your array and add to it. Or have an attribute of Dex_base, Dex_add and Dex_multi which is combined when a Dex_actual is needed and add to the Dex_add instead so the multiplication won't complicate it.
Realy good video but How do you need to organize some inventory system with different values between each object.
for example, I am creating a Survival game in which each type of wood has different characteristics that are used for different things, or even with minerals with strength, toughness and etc. but a Struct can´t have different values in its columns. What would be a solution?
VERY tnx, my lord
And what about Remove node? Donesn't accept a - node, how can i remove a set amount of objects from a map?
Is there a quick way to compare the exact content of two maps? like whether map1 = map2 without worrying about the order of their elements but only key-value pairs
Hey, not sure if you know this, but you can use "Set" instead of maps, to compare the exact contents. If you need to use maps, then unfortunately I don't think there is a way, not that I can see anyways.
@@PJBurrows91 Ye I just ended up making my own mapEquals function.....
Hey Ryan, please explain an example about DLC sample
You are able to do this in unreal engine 4?