I am an unity switcher and would like to know if there’s anything in UE4 that could be used to accomplish the same thing that tags and layers for objects do in unity. Tags are used in unity just to give a name to an object and then look for it (I guess it is different from the name property in that the tag should use some short of hash in a map for faster retrieval). Layers are used to group objects in the scene. Something like Floor, Enemies, etc… It is really handy for example for Raycast operations. I have been looking through the API and did not find any information about this or something that could be used instead.
For tags, your best would be to use… tags. AActor has an array of strings called “Tags” that works fairly similarly to Unity’s tags. AActor also has the function HasTag() to determine if an object has a given tag. UE4 doesn’t have, to my knowledge (though I’ve only been working with it for four months, so I could be wrong here), an equivalent to the static method FindObjectsWithTag(), but it’s relatively easy to iterate through Actors to retrieve the one or ones you want, sort of like this (warning - uncompiled code from memory here):
for (TActorIterator<AActor> ActorIterator(GetWorld()); ActorIterator; ++ActorIterator )
{
AActor *TestActor = Cast<AActor>(*ActorIterator);
if (TestActor->ActorHasTag(tag) || tag == NAME_None)
{
// This Actor has the tag, so do something..
}
}
For layers, are you talking about physics layers? If so, take a look at the documentation for collision filtering. It’s conceptually similar and should accomplish what you want.