Back to search
PatternGold tierPerformance

Object pooling: reuse actors instead of spawn/destroy

Updated 3mo ago1 look-ups
UE 5.3UE 5.4UE 5.5UE 5.6UE 5.7#pool#object#reuse#spawn#performance#optimize

Reference

Variables in pool manager (GameMode or Subsystem): Pool (Array<Actor>), PoolClass (TSubclassOf<Actor>).

Init: Loop N times → SpawnActorFromClass → SetActorHiddenInGame(true) → SetActorEnableCollision(false) → SetActorTickEnabled(false) → Array Add to Pool.

GetFromPool: ForEachLoop(Pool) → GetActorHiddenInGame → Branch(true) → SetActorHiddenInGame(false) → SetActorEnableCollision(true) → SetActorTickEnabled(true) → SetActorLocationAndRotation → Return actor. If none available: SpawnActorFromClass.

ReturnToPool: SetActorHiddenInGame(true) → SetActorEnableCollision(false) → SetActorTickEnabled(false) → SetActorLocation(far away or (0,0,-9999)).