UGameplayStatics::GetAllActorsWithTag returns incorrectly? {5.1}

What’s even weirder is the blueprint version returns fine?

Its on a subsystem that I made if that makes a difference but that should even matter because Im still grabbing some of the actors.

I set it up as I should too: an array of actors above the call labeled actors and I make the output array from the function said array

After the initial function call I iterate using a simple foreach and I debug the editor label for each actor in the array and I get a result that looks similar to

Actor3
Actor3
Actor1

Its literally skipping one of my 3 actors in the scene and duplicating an actor already in the array and its frustrating because this should work without issue, how did they ruin such a simple function?

Same thing happens with actors of class too

EDIT Code:

TArray<AActor*> speakers;
UGameplayStatics::GetAllActorsWithTag(GetWorld(), "Speaker", speakers);

for (AActor* speaker : speakers)
{
	GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Green, speaker->GetActorLabel());

}

EDIT #2 : so the problem gets weirder with the more actors you add, It seems like its skipping every other actor and duplicating the last actor in the array enough times to fill in the gaps

for example this is what happens when you have 5 actors

Actor5
Actor5
Actor5
Actor3
Actor 1

Such a bizarre bug

Try using GetFullName() instead of GetActorLabel()

I ended up asking chatgpt and apparently i was just an idiot for prematurely removing actors from the array

(For context my goal was to remove actors i needed from the array after I performed special methods on them and the actors left over would get separate functions called)

so I instead made a separate array that I added the actors that passed the first test too and in the second iteration I just checked to see if it was in the new array, and if it wasnt I performed the second iteration functions

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.