UActorComponent::ComponentHasTag
#include "Components/ActorComponent.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Returns true if the component's ComponentTags array contains the given tag. Component tags are separate from actor tags and must be managed independently.
Caveats & Gotchas
- • ComponentTags are separate from the owning actor's Tags array. Checking ComponentHasTag on a component does NOT check the actor's tags. Use AActor::ActorHasTag for actor-level tags.
- • Tag comparison is case-sensitive (FName comparison). Ensure consistent casing when adding and querying tags, as 'enemy' and 'Enemy' are different FNames.
Signature
UFUNCTION(BlueprintCallable, Category="Components")
ENGINE_API bool ComponentHasTag(FName Tag) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Tag | FName | The tag name to search for in this component's ComponentTags array. | — |
Return Type
bool Example
Filter components by tag during overlap C++
void AMyActor::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& Hit)
{
if (OtherComp && OtherComp->ComponentHasTag(FName("Interactable")))
{
HandleInteraction(OtherActor);
}
} See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?