AActor::GetComponentsByTag
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Returns all components on this actor that are of type ComponentClass and have the specified tag. Use FindComponentByTag() if you only need the first match.
Caveats & Gotchas
- • Queries component tags (the ComponentTags array on UActorComponent), not actor tags (AActor::Tags). These are distinct and not interchangeable.
- • Allocates a new TArray on every call. Cache the result if you need it more than once per frame.
- • The returned base pointers must be cast to the desired type in C++. Blueprint handles this automatically via the DeterminesOutputType metadata.
Signature
ENGINE_API TArray<UActorComponent*> GetComponentsByTag(TSubclassOf<UActorComponent> ComponentClass, FName Tag) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| ComponentClass | TSubclassOf<UActorComponent> | The component class to filter by. | — |
| Tag | FName | The component tag all returned components must have. | — |
Return Type
TArray<UActorComponent*> Example
Disable all components marked with a specific tag C++
TArray<UActorComponent*> HitboxComponents = GetComponentsByTag(UPrimitiveComponent::StaticClass(), FName("Hitbox"));
for (UActorComponent* Comp : HitboxComponents)
{
Comp->SetActive(false);
} Tags
Version History
Introduced in: 4.17
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?