Download

ObjectIterator

Hi all,

In MyController.cpp i have :


for (TObjectIterator<ACubesManager> Itr(GetWorld()); Itr; ++Itr)
	{
		if (Itr->IsA(ACubesManager::StaticClass()))
		{
			//CubesManager = Itr;
		}
		else
		{
			continue;
		}
	}

compiler refuses “GetWorld()”.

How to Object iterate only AcubesManager class instances placed in the world please ?

You should use this:


for (TActorIterator<AActor> Itr(GetWorld(), ACubesManager::StaticClass()); Itr; ++Itr)
	{
	
	}

Thanks Mhousse1247, it worked.

How please can i get the pointer of the pawn stocked in Itr please ?

when i tried (CubesManager type is ACubesManager* )


for (TActorIterator<ACubesManager> Itr(GetWorld(), ACubesManager::StaticClass()); Itr; ++Itr)
	{
		if (Itr->IsA(ACubesManager::StaticClass()))
		{
			CubesManager = Itr ;
		}
		else
		{
			continue;
		}
	}

}

the compiler pointed out errors

Your need this
CubesManager = *Itr;

Thank you so much