Finding Actors

A tutorial on how to find Actors in your scene by using Blueprint Scripting / C++.

Once your projects begin to increase in scale, you may find it difficult to locate an individual Actor in your scene. It is common to have hundreds of Actors in your scene ranging from level set pieces and geometry, to NPCs, enemies, interactable objects, and pick-ups. When working in the Unreal Editor, You can use the World Outliner to assist in finding an Actor in your scene.

image alt text

In the image above, the World Outliner (right) represents all the Actors that are placed inside your level. Clicking on one of the Actors in the World Outliner highlights it inside the level viewport as well. You can sort the World Outliner by Actor Name or by Actor Type by clicking on the Actor or Type headers (you can change the secondary category from Type to other filters by clicking the down arrow in the Type Box).

With an Actor selected in the World Outliner, and while navigating inside the Level Viewport, double-clicking the Actor or pressing the F key will move the camera to the location of the Actor selected to Focus on it.

Refer to the World Outliner documentation for more information on locating an Actor in your scenes.

Choose your implementation method:

Blueprints

C++

Project Setup

In this tutorial, you will find Actors in a Level by using the Get All Actors of Class node. When this node is called it will retrieve all Actors in your Level of the specified Class and place them in an Array. Then, from that Array, you can retrieve an Actor or Actors based on your filter criteria. You can then access the properties of the Actor(s) or modify them in some way based on the functionality you want to achieve.

  1. Begin by creating a New > Games > ThirdPerson > Blueprint Project with Starter Content, named FindingActors.

    Click for full view.

  2. Navigate to Edit > Project Settings > Engine > Input > Bindings > Action Mappings, then click Add(+) to create a new action mapping named FindActorPressed, then set the key value to 1.

    Click for full view.

In this tutorial, you will find Actors in a Level by using the Gameplay Statics Class Library (Get All Actors of Class node). When this Function (node) is called, it will retrieve all Actors in your Level of the specified Class and place them in an Array. Then, from that Array, you can retrieve all Actors or an Actor based on any filter criteria. You can then access the properties of the Actor(s) or modify them in some way based on the functionality you want to achieve.

  1. Begin by creating a New > Games > ThirdPerson > C++ Project with Starter Content named FindingActors.

    Click for full view.

  2. Navigate to the Edit > Project Settings > Engine > Input > Bindings > Action Mappings, then click Add(+) to create a new action mapping named FindActorPressed, then set the key value to 1.

    Click for full view.

Creating the FireEffect Actor

The Starter Content folder provides a completed FireEffect Actor that includes a Particle Component to represent the flame effect, and an Audio Component for the sound effects. This Actor will be used as the base Actor class to find from the Get All Actors of Class node.

Navigate to Content > StarterContent > Blueprints, then drag an instance of Blueprint_Effect_Fire into the World.

![](03_BPDragBPEffectFire.png)

  1. Click the Add button to create a New C++ Class then from the Choose a Parent Class menu, select Actor, click Next.

    Click for full view.

  2. Name your new Actor class FireEffect and click Create Class.

    Click for full view.

  3. In FireEffect.h, declare the following:

    public:
        //Get the fire sound effect Audio Component.
        UAudioComponent* GetFireAudioComponent() const { return FireAudioComponent; }
    
        //Get the fire effects Particle System Component.
        UParticleSystemComponent* GetParticleFireComponent() const { return ParticleFireComponent; }
    
    protected:
        UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
        UParticleSystemComponent* ParticleFireComponent;
    
        UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
        UAudioComponent* FireAudioComponent;
  4. Navigate to the FireEffect.cpp file, then include the following class libraries:

    #include "Particles/ParticleSystemComponent.h"
    #include "Components/AudioComponent.h"
  5. In the AFireEffect constructor, implement the following code:

    AFireEffect::AFireEffect()
    {
        // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
        PrimaryActorTick.bCanEverTick = true;
        ParticleFireComponent = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("P_Fire"));
        FireAudioComponent = CreateDefaultSubobject<UAudioComponent>(TEXT("Fire Audio"));
        ParticleFireComponent->SetupAttachment(RootComponent);
        FireAudioComponent->AttachToComponent(ParticleFireComponent,FAttachmentTransformRules::KeepRelativeTransform);
    }
  6. Compile your code.

  7. Navigate to Content Browser > C++ Classes > FindingActors and right-click the FireEffect Actor to Create a Blueprint class based on FireEffect named BP_FireEffect.

    ![](05_CreateBPClassBased.png)(w:600)

  8. In the Class Defaults of BP_FireEffect, click Particle Fire in the Components panel, then navigate to the Details panel, then under the Particles category open the Template dropdown menu and choose P_Fire.

    ![](06_AddTemplateToBPFireEffect.png)

  9. Click Fire Audio in the Components panel, then navigate to the Details panel. From the Sound category, open the Sound variable dropdown menu and choose Fire01_Cue.

    ![](07_AddSoundToBPFireEffect.png)

  10. Click Compile and Save.

    ![](08_CompileSaveButton.png)

Finished Code

FireEffectActor.h

    #pragma once

    #include "CoreMinimal.h"
    #include "GameFramework/Actor.h"
    #include "FireEffect.generated.h"

    UCLASS()
    class FINDINGACTOR_API AFireEffect : public AActor
    {
        GENERATED_BODY()

    public: 
        // Sets default values for this actor's properties
        AFireEffect();

    protected:
        // Called when the game starts or when spawned
        virtual void BeginPlay() override;

    public: 
        // Called every frame
        virtual void Tick(float DeltaTime) override;

    public:
        //Get the fire sound effect Audio Component.
        UAudioComponent* GetFireAudioComponent() const { return FireAudioComponent; }

        //Get the fire effects Particle System Component.
        UParticleSystemComponent* GetParticleFireComponent() const { return ParticleFireComponent; }

    protected:
        UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
        UParticleSystemComponent* ParticleFireComponent;

        UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
        UAudioComponent* FireAudioComponent;
    };

FireEffectActor.cpp

    #include "FireEffect.h"
    #include "Particles/ParticleSystemComponent.h"
    #include "Components/AudioComponent.h"

    // Sets default values
    AFireEffect::AFireEffect()
    {
        // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
        PrimaryActorTick.bCanEverTick = true;
        // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.

        PrimaryActorTick.bCanEverTick = true;
        ParticleFireComponent = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("P_Fire"));
        FireAudioComponent = CreateDefaultSubobject<UAudioComponent>(TEXT("Fire Audio"));
        ParticleFireComponent->SetupAttachment(RootComponent);
        FireAudioComponent->AttachToComponent(ParticleFireComponent, FAttachmentTransformRules::KeepRelativeTransform);
    }

    // Called when the game starts or when spawned
    void AFireEffect::BeginPlay()
    {
        Super::BeginPlay();
    }

    // Called every frame
    void AFireEffect::Tick(float DeltaTime)
    {
        Super::Tick(DeltaTime);
    }

Third Person Character: Setting Up the Finding Actor Pressed Event

  1. Navigate to the Content > ThirdPerson > Blueprints folder and double click the BP_ThirdPersonCharacter to open its Class Defaults.

    ![](04_OpenBPThirdPersonCharacter.png)

  2. Right-click on the Event Graph, then from the Actions menu search for the FindActorPressed action key event.

    Copy Node Graph

    ![](05_BPScript01.png)

  3. From the FindActorPressed node Key Event, drag off from the Pressed pin, then from the Actions menu, search for the Get All Actors Of Class node.

    Copy Node Graph

    ![](06_BPScript02.png)

  4. Inside the Get All Actors of Class node, click the Actor Class, then from the drop-down select the Blueprint_Effect_Fire class.

    ![](07_BPScript03.png)

  5. Drag off from the Out Actors pin and in the Actions menu, search for For Each Loop.

    Copy Node Graph

    ![](08_BPScript04.png)

  6. Drag off from the Execution pin of the Get All Actors Of Class node and plug it into the Exec pin of the For Each Loop node.

    Copy Node Graph

    ![](09_BPScript05.png)

  7. From the ForEachLoop node, drag off the Array Element pin, then in the Actions menu, search for Get P Fire.

    Copy Node Graph

    ![](10_BPScript06.png)

  8. Drag off from the Array Element pin, then in the Actions menu, search for Get Fire Audio.

    Copy Node Graph

    ![](11_BPScript07.png)

  9. Drag off from the P Fire pin, then in the Actions menu search for the Deactivate node.

    Copy Node Graph

    ![](12_BPScript08.png)

  10. Drag off from the Fire Audio pin and connect it to the Target pin from the Deactivate node.

    Copy Node Graph

    ![](13_BPScript09.png)

  11. Click Compile and Save.

    ![](14_CompileSaveButton.png)

  1. From the Content Browser, navigate to C++ Classes > FindingActors and double-click FindingActorsCharacter to open the FindingActorsCharacter.h file.

    ![](09_OpenFindingActors.png)

  2. In the FindingActorsCharacter class defaults, declare the following:

    protected:
        void OnFindActorPressed();
  3. Navigate to FindingActorsCharacter.cpp and include the following class libraries:

    #include "Kismet/GameplayStatics.h"
    #include "FireEffect.h"
    #include "Particles/ParticleSystemComponent.h"
    #include "Components/AudioComponent.h"

    Unreal Engine uses an Include-What-You-Use (IWYU) dependency model. This means that the Engine's source code only includes the dependencies that it needs to compile. See IWYU for additional documentation.

  4. Implement the logic for your OnFindActorPressed by declaring the following code:

    void AFindingActorsCharacter::OnFindActorPressed()
    {
        TArray<AActor*> ActorsToFind;
        if(UWorld* World = GetWorld())
        {
        UGameplayStatics::GetAllActorsOfClass(GetWorld(), AFireEffect::StaticClass(), ActorsToFind);
        }
        for (AActor* FireEffectActor: ActorsToFind)
        {
            //Is this Actor of type FireEffect class?
            AFireEffect* FireEffectCast = Cast<AFireEffect>(FireEffectActor);
            if (FireEffectCast)
            {
                //Get the Particle Fire Component and deactivate it.            
                FireEffectCast->GetParticleFireComponent()->Deactivate();
    
                //Get the Fire Audio Component and deactivate it.           
                FireEffectCast->GetFireAudioComponent()->Deactivate();
            }   
        }
    }
  5. Navigate to the SetupPlayerInputComponent method and declare the following code:

    void AFindingActorsCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
    {
        PlayerInputComponent->BindAction("FindActorPressed", IE_Pressed, this, &AFindingActorsCharacter::OnFindActorPressed);
    }
  6. Compile your code.

Finished Blueprint

Copy Node Graph

![](15_BPScriptFinal1.png)

Finished Code

FindingActorsCharacter.h

    #pragma once

    #include "CoreMinimal.h"
    #include "GameFramework/Character.h"
    #include "FindingActorsCharacter.generated.h"

    UCLASS(config=Game)

    class AFindingActorsCharacter : public ACharacter

    {
        GENERATED_BODY()

        /** Camera boom positioning the camera behind the character */
        UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
        class USpringArmComponent* CameraBoom;

        /** Follow camera */
        UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
        class UCameraComponent* FollowCamera;

    public:

        AFindingActorsCharacter();

        /** Base turn rate, in deg/sec. Other scaling may affect final turn rate. */
        UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Input)
        float TurnRateGamepad;

    protected:

        /** Called for forwards/backward input */
        void MoveForward(float Value);

        /** Called for side to side input */
        void MoveRight(float Value);

        /** 
         * Called via input to turn at a given rate. 
         * @param Rate  This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
         */
        void TurnAtRate(float Rate);

        /**
         * Called via input to turn look up/down at a given rate. 
         * @param Rate  This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
         */
        void LookUpAtRate(float Rate);

        /** Handler for when a touch input begins. */
        void TouchStarted(ETouchIndex::Type FingerIndex, FVector Location);

        /** Handler for when a touch input stops. */
        void TouchStopped(ETouchIndex::Type FingerIndex, FVector Location);

    protected:

        // APawn interface
        virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
        // End of APawn interface

    public:

        /** Returns CameraBoom subobject **/
        FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }

        /** Returns FollowCamera subobject **/
        FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }

    protected:

        /** Called when Input key is pressed from the Player input component */
        void OnFindActorPressed();
    };

FindingActorsCharacter.cpp

    #include "FindingActorsCharacter.h"
    #include "Camera/CameraComponent.h"
    #include "Components/CapsuleComponent.h"
    #include "Components/InputComponent.h"
    #include "GameFramework/CharacterMovementComponent.h"
    #include "GameFramework/Controller.h"
    #include "GameFramework/SpringArmComponent.h"
    #include "Kismet/GameplayStatics.h"
    #include "FireEffect.h"
    #include "Particles/ParticleSystemComponent.h"
    #include "Components/AudioComponent.h"

    //////////////////////////////////////////////////////////////////////////
    // AFindingActorsCharacter

    AFindingActorsCharacter::AFindingActorsCharacter()
    {
        // Set size for collision capsule
        GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);

        // set our turn rate for input
        TurnRateGamepad = 50.f;

        // Don't rotate when the controller rotates. Let that just affect the camera.
        bUseControllerRotationPitch = false;
        bUseControllerRotationYaw = false;
        bUseControllerRotationRoll = false;

        // Configure character movement
        GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...   
        GetCharacterMovement()->RotationRate = FRotator(0.0f, 500.0f, 0.0f); // ...at this rotation rate

        // Note: For faster iteration times these variables, and many more, can be tweaked in the Character Blueprint
        // instead of recompiling to adjust them
        GetCharacterMovement()->JumpZVelocity = 700.f;
        GetCharacterMovement()->AirControl = 0.35f;
        GetCharacterMovement()->MaxWalkSpeed = 500.f;
        GetCharacterMovement()->MinAnalogWalkSpeed = 20.f;
        GetCharacterMovement()->BrakingDecelerationWalking = 2000.f;

        // Create a camera boom (pulls in towards the player if there is a collision)
        CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
        CameraBoom->SetupAttachment(RootComponent);
        CameraBoom->TargetArmLength = 400.0f; // The camera follows at this distance behind the character   
        CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller

        // Create a follow camera
        FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
        FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
        FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm

        // Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character) 
        // are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++)
    }

    //////////////////////////////////////////////////////////////////////////
    // Input

    void AFindingActorsCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
    {
        // Set up gameplay key bindings
        check(PlayerInputComponent);
        PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
        PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);

        PlayerInputComponent->BindAxis("Move Forward / Backward", this, &AFindingActorsCharacter::MoveForward);
        PlayerInputComponent->BindAxis("Move Right / Left", this, &AFindingActorsCharacter::MoveRight);

        // We have 2 versions of the rotation bindings to handle different kinds of devices differently
        // "turn" handles devices that provide an absolute delta, such as a mouse.
        // "turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick
        PlayerInputComponent->BindAxis("Turn Right / Left Mouse", this, &APawn::AddControllerYawInput);
        PlayerInputComponent->BindAxis("Turn Right / Left Gamepad", this, &AFindingActorsCharacter::TurnAtRate);
        PlayerInputComponent->BindAxis("Look Up / Down Mouse", this, &APawn::AddControllerPitchInput);
        PlayerInputComponent->BindAxis("Look Up / Down Gamepad", this, &AFindingActorsCharacter::LookUpAtRate);

        // handle touch devices
        PlayerInputComponent->BindTouch(IE_Pressed, this, &AFindingActorsCharacter::TouchStarted);
        PlayerInputComponent->BindTouch(IE_Released, this, &AFindingActorsCharacter::TouchStopped);

        PlayerInputComponent->BindAction("FindActorPressed", IE_Pressed, this, &AFindingActorsCharacter::OnFindActorPressed);
    }

    void AFindingActorsCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
    {
        Jump();
    }

    void AFindingActorsCharacter::TouchStopped(ETouchIndex::Type FingerIndex, FVector Location)
    {
        StopJumping();
    }

    void AFindingActorsCharacter::TurnAtRate(float Rate)
    {
        // calculate delta for this frame from the rate information
        AddControllerYawInput(Rate * TurnRateGamepad * GetWorld()->GetDeltaSeconds());
    }

    void AFindingActorsCharacter::LookUpAtRate(float Rate)
    {
        // calculate delta for this frame from the rate information
        AddControllerPitchInput(Rate * TurnRateGamepad * GetWorld()->GetDeltaSeconds());
    }

    void AFindingActorsCharacter::MoveForward(float Value)
    {
        if ((Controller != nullptr) && (Value != 0.0f))
        {
            // find out which way is forward
            const FRotator Rotation = Controller->GetControlRotation();
            const FRotator YawRotation(0, Rotation.Yaw, 0);

            // get forward vector
            const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
            AddMovementInput(Direction, Value);
        }
    }

    void AFindingActorsCharacter::MoveRight(float Value)
    {
        if ( (Controller != nullptr) && (Value != 0.0f) )
        {
            // find out which way is right
            const FRotator Rotation = Controller->GetControlRotation();
            const FRotator YawRotation(0, Rotation.Yaw, 0);

            // get right vector 
            const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
            // add movement in that direction
            AddMovementInput(Direction, Value);
        }
    }

    void AFindingActorsCharacter::OnFindActorPressed()
    {
        TArray<AActor*> ActorsToFind;
        if (UWorld* World = GetWorld())
        {
            UGameplayStatics::GetAllActorsOfClass(GetWorld(), AFireEffect::StaticClass(), ActorsToFind);
        }
        for (AActor* FireEffectActor : ActorsToFind)
        {
            //Is this Actor of type FireEffect class?
            AFireEffect* FireEffectCast = Cast<AFireEffect>(FireEffectActor);
            if (FireEffectCast)
            {
                //Get the Particle Fire Component and deactivate it.            
                FireEffectCast->GetParticleFireComponent()->Deactivate();

                //Get the Fire Audio Component and deactivate it.           
                FireEffectCast->GetFireAudioComponent()->Deactivate();
            }
        }
    }

End Result

Navigate to the Toolbar and click Play (PIE).

![](16_PlayButton.png)

When pressing the numeric 1 key, you should notice the Fire effect particles will extinguish and the sound effects emitting from the audio component will no longer be heard.

  1. Navigate to Content Browser, and drag a few instances of your BP_FireEffect into the Level.

    Click for full view.

  2. Navigate to the Toolbar and click Play (PIE).

    ![](11_PlayButton.png)

  3. When pressing the numeric 1 key, you should notice the Fire effect particles will extinguish and the sound effects emitting from the audio component will no longer be heard.

Get Specific Actors with Tag

You used the Get All Actors of Class node to get an Array of Actors of a specified Class. However, you can also filter the Array results based on different criteria to get specific Actors or a single Actor from the Array by using Tags on the Actor.

  1. Navigate to the Content > StarterContent > Blueprints and select Blueprint_Effect_Fire.

    ![](18_SelectBPEffectFire.png)

  2. In the Details panel, navigate to the Tags section and click Add(+) to add a tag to the Actor.

    ![](19_BPEffectFireDetails.png)

  3. In the 0 element field, enter "FindActorTag" into the text string.

    ![](20_BPEffectFireTag.png)

  4. Inside the MyCharacter Blueprint, drag off from the Array Element pin of the For Each Loop and in the Actions menu search for Get Tags.

    Copy Node Graph

    ![](21_BPScript10.png)

  5. Drag off from the Tags pin, then in the Actions menu search for the Get(a copy) node.

    Copy Node Graph

    ![](22_BPScript11.png)

    Here we are "Getting" the Tag at Index 0 which we set as FindActorTag above.

  6. Your Blueprint Script should look as following:

    Copy Node Graph

    ![](23_BPScript12.png)

  7. Drag off from the Execution pin of the For Each Loop node, then in the Actions menu search for the Branch node.

    Copy Node Graph

    ![](24_BPScript13.png)

  8. Drag off from the Condition pin of the Branch node and add an Actor Has Tag node.

    Copy Node Graph

    ![](25_BPScript14.png)

  9. Connect the out pin from the Get node to the Tag pin on the Actor Has Tag node.

    ![](26_BPScript15.png)

  10. Connect the Array Element pin of the For Each Loop node to the Target pin on the Actor Has Tag node. Your Blueprint Script should look as following:

    ![](27_BPScript16.png)

  11. Connect the True pin of the Branch node with Exec Pin of the Deactivate node.

    ![](28_BPScript17.png)

  12. Your Blueprint Script should look as following:

    Copy Node Graph

    ![](29_BPScriptFinal2.png)

  13. Click Compile and Save.

    ![](30_CompileSaveButton.png)

  14. Select one of your Blueprint_FireEffect's from the Outliner, then from the Details panel navigate to the Tags variable, locate the FindActorTag field, open the drop-down menu, then select Delete to delete the tag variable.

    ![](31_BPEffectFireDelTag.png)

    We are intentionally leaving one of the fire effects without a tag in order to demonstrate the functionality.

  15. Navigate to the Toolbar and Press Play (PIE).

    ![](32_PlayButton.png)

You used the GetAllActorsofClass function from the Gameplay Statics Library, to get an Array of Actors of a specified Class. However, you can also filter the Array results based on different criteria to get specific Actors or a single Actor from the Array by using Tags on the Actor.

  1. Begin by navigating to your Content Browser > C++ Classes folder, and double click your FireEffect Actor to open it's FireEffect.cpp file.

    ![](12_OpenFireEffect.png)

  2. Inside the FireEffect constructor add the following code

    AFireEffect::AFireEffect()
    {
        Tags.Add(FName("FindActorTag"));
    }

    Tags is an array that is a part of the Actor's class defaults, It can be used for grouping and categorizing.

  3. Compile your code.

  4. Open your BP_FireEffect, then in the Details panel, navigate to the Actor category and you will notice your Actor Tag has been created.

    ![](13_AddedActorTag.png)

  5. Navigate to your Content Browser > C++ Classes Folder, and double-click your FindingActorsCharacter to open its FindingActorsCharacter.cpp file.

    ![](14_OpenFindingActors.png)

  6. In the OnFindActorPressed method implement the following:

    void AFindingActorsCharacter::OnFindActorPressed()
    {
    
        TArray<AActor*> ActorsToFind;
    
        //Gets all Actors of FireEffect class that have the "FindActorTag"
        UGameplayStatics::GetAllActorsOfClassWithTag(GetWorld(), AFireEffect::StaticClass(), FName("FindActorTag"),ActorsToFind);
    
        for (AActor* FireEffectActor: ActorsToFind)
        {
            AFireEffect* FireEffectCast = Cast<AFireEffect>(FireEffectActor);
    
            if (FireEffectCast)
            {
                //Get the Particle Fire Component and deactivate it.
                FireEffectCast->GetParticleFireComponent()->Deactivate();
    
                //Get the Fire Audio Component and deactivate it. 
                FireEffectCast->GetFireAudioComponent()->Deactivate();
            }   
        }
    }
  7. Compile your Code.

  8. Select one of your BP_FireEffect instances in the Level Viewport, then in the Details panel navigate to the Tags variable, locate the FindActorTag field and open the dropdown menu next to it to delete the variable.

    ![](15_BPEffectFireDelTag.png)

  9. Navigate to the Toolbar and click Play (PIE).

    ![](16_PlayButton2.png)

End Result

When pressing the numeric 1 key, you should notice all Bluprint_Fire_ Effect particles with the ActorsToFindTag are extinguished, while the fire effect without the tag remains.

When pressing the numeric 1 key, you should notice all BP_FireEffect particles with the FindActorsTag are extinguished, while the fire effect without the tag remains.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Cancel