I managed to iterate over the actors in my game (thanks for his tutorials) by using this
for (TObjectIterator<AStaticMeshActor> act; act; ++act)
FString actorName = act->GetName();
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Actor %s"), *actorName));
My question is, how can I get the actor from the TObjectIterator?
I’d like to have AStaticMesh actor or AActor instead of the iterator.
Thanks for pointing me in the right direction
(and yes I’m not experienced in c++, sorry )
You already accessing it:
TObjectIterator have “->” and
* operators overrided, they return current item in iterator. You use “*” to point to object in iterator, like this:
You don’t even need to cast, it returns in type you defined in template
Try to rebuild, also i not sure if this is related but by convetions used in UE4 all functions and varables names should start with uppercase letter, UHT read those to generate those files so it might be a cause.
hmm the code works but not the task I like to finish
could using a pointer be the reason for this problem?
(short sum up, I cannot attach the actor I’m iterating through)
Hi, I’m trying to do this (see screenshot ) in c++ I want to attach AStaticMeshActor (NightwishStaff) to a socket. I wrote a blueprint callable function which looks like this: void AManaJourneyCharacter::equipItem(AActor* actorToEquip, FName...