Community Tutorial: Using Custom C++ Structs as TMap Keys in Unreal Engine

Tutorial on how to setup a USTRUCT to be used as a key in a TMAP.

https://dev.epicgames.com/community/learning/tutorials/GxZ9/using-custom-c-structs-as-tmap-keys-in-unreal-engine

2 Likes

Thank you SOOO much!
I was getting frustrated trying to figure out, on how to create Default-Values for a TMap.

UPROPERTY(BlueprintReadWrite, EditAnywhere, meta=(DisplayName = “Spotting Accuracy (Meters)”))
TMap<float,FSpottingAccuracy> SpottingAccuracyMeters
{
{1000,FSpottingAccuracy{
EVisionLevelOfIdentification::EquipmentDetailed,90,100}},
{2000,FSpottingAccuracy{
EVisionLevelOfIdentification::SuspectDetailed,50,100}},
{3000,FSpottingAccuracy{
EVisionLevelOfIdentification::UnknownBasic,10,100}}
};

Tried almost everything prior to your solution, so again: thank you very much for the effort!

1 Like

Copy/Paste
// (c) blurryroots innovation qanat OÜ – CC BY 4.0

blurryroots? Der Name kommt mir doch bekannt vor :smiley:

Schöne Grüße aus Göttingen,
RamĂłn Janousch

1 Like

Aloha Ramon, welch Adleraugen! :blush: Beste GrĂĽĂźe auch an dich.

1 Like

@DaveTheFreak Year it can get quite tricky. Really glad I could help you out with this.

It didn’t compile for me then I looked at the source code for examples and saw they were using “friend”, did the same and it passed compilation.