GameplayStatics/GetActorArrayBounds
Find the bounds of an array of actors. Include #include "Kismet/GameplayStatics.h" Syntax static void GetActorArrayBounds(const TArray& Actors, bool bOnlyCollidingComponents, FVector&...
Find the bounds of an array of actors.
Include
#include "Kismet/GameplayStatics.h"
Syntax
static void GetActorArrayBounds(const TArray& Actors, bool bOnlyCollidingComponents, FVector& Center, FVector& BoxExtent)
Parameters
Actors
The array of actors in which you you want the actor array bounds around.
bOnlyCollidingComponents
Only consider components that are collideable. A non collideable component might be a trigger location that is query only.
Center
Output variable containing the world position FVector Center.
BoxExtent
Output variable containing the world position FVector Extents. The extents are like the width, height, and length of a box.
Examples
Real world use cases:
Example 1
Perhaps you have have a game where you have the enemy surround all the players but not get in between any players. With this, you will get a bounding cube (a center and its extents of all the players characters.
// Types
TArray Players;
...
// Done frequently
FVector OutCenter;
FVector OutBoxExtent;
UGameplayStatics::GetActorArrayBounds(Players, true, OutCenter, OutBoxExtent);
// OutCenter and OutBoxExtent now contain the output from GetActorArrayBounds.
// Make believe function that tells the enemy what to surround.
EnemyMind.UpdateBoxToSurroundPlayers(OutCenter, OutBoxExtent);