Skip to main content
  1. Posts/

TActorIterator and TActorRange

English Post Programming UnrealEngine C++ Unreal Engine

If you want to collect class-specific actors that spawned in the world you can use TActorIterator.

for (TActorIterator<ACharacter> Iter(GetWorld()); Iter; ++Iter)
{
    ACharacter* Character = *Iter;
    //If IsValid
    Character->Func();
}

There is also a version of the Ranged For feature available in C++11.

It’s called TActorRange. With this, we can iterate it safer and easier.

for (ACharacter* Character : TActorRange<ACharacter>(GetWorld()))
{
    //If IsValid
    Character->Func();
}

Related

How To Check Viewport Is Focused
English Post Programming UnrealEngine C++ Unreal Engine
How To Check Class Is From Native Or Blueprint
English Post Programming UnrealEngine C++ Unreal Engine Class
How To Iterate Over UENUM
English Post Programming Unreal Engine C++ Unreal Engine Enum
Controlling C++ Compile Optimization
English Post Programming C++
Quantized (양자화) 되었다는 의미와 사용하는 이유
Korean Post Unreal Engine Programming Unreal Engine Network Optimize
C++ Compile Optimization 일부분만 해제하는 방법
Korean Post Programming C++ Optimize