I’m attempting to append an array of actor objects to another array of actor objects. I’m using the second array to build a list of actors to ignore for collision checks. There must be something I’m missing, either about the append function itself, or assigning arrays of actors, but I cannot figure out what it could be.
Here’s the code I’m using.
In the class declaration
// Array of Triggers in the level TArray<AActor*> TriggersInLevel;
In the On Begin Play function
// Get all the triggers in the level so that they may be referenced. UGameplayStatics::GetAllActorsOfClass(GetWorld(), ATriggerBox::StaticClass(), TriggersInLevel);
In the collision check function
TArray<AActor*> ActorsToIgnore; ActorsToIgnore.Append(TriggersInLevel, TriggersInLevel.Num() - 1);
The error I’m getting on the append is
no instance of overloaded function matches the argument list argument types are: (TArray<AActor *, FDefaultAllocator>, int) object type is: TArray<AActor *, FDefaultAllocator>
The collision check function is neither static, nor constant, so I can see no reason this won’t work. Also, directly assigning the ‘Triggers in level’ array to the ‘Actors to ignore’ array works just fine.
This works, append does not.
TArray<AActor*> ActorsToIgnore = TriggersInLevel;
I’d like to append because the ignored actors array is likely to contain other actors as needed. Any help on this would be appreciated, thanks.