Download

TMap can find the value but can't return it?

Hello, I’m using a TMap on my actor so I can drag other actors into it and reference them easily in code.
I’ve been doing this all over the game and it’s always worked perfectly, but something’s not working right on this one:


UPROPERTY(EditAnywhere, Category = "AKQ|Assets") TMap<FName, AActor*> Actors;


	
for (auto& Elem : Actors){
	UT::Pop(Elem.Key.ToString(), !!Elem.Value);
}
UT::Pop("Contains", Actors.Contains("hurt"));
UT::Pop("Actors]", !!Actors"hurt"]);
UT::Pop("Actors.FindRef", !!Actors.FindRef("hurt"));

The UT::Pop() just prints a message to the screen.
When I run this code, it prints the following:

hurt: true
Contains: true
Actors]: false
Actors.FindRef: false

Why does it clearly see that there’s a ‘hurt’ element in the TMap, but it fails to actually find or use it? What’s going on here?

Edit: Apparently it just breaks on every compile, and I have to either add an empty element to the end, or remove that empty element.
The TMap has to be changed in some way every compile or everything is null.

I found something strange going on with TMap too, it seems related. I had just started using a TMap uproperty to store some pre-calculated data about my StaticMeshActors but whenever I press Play the table loses all its value data, becoming completely useless. At first I thought it was because of key pointers changing between editor and play, but using the actors’ name as key doesn’t resolve the problem like it should.

To be clear, it was working perfectly until two days ago, and I’m 99% sure I didn’t touch anything related to the TMap since my previous backup now shows the same behaviour. I’m now using UE 4.15.3 but I noticed this since the 3.0.1 update of the launcher.

I know this is old but for anyone else who encounters similar issues:
I recently found that using “MyMap->Find(key)” wasn’t working, and I had to use the old school method of grabbing it: “MyMap[key]”.