How do I find a specific object in the world?

I am new to UE and C++. I am trying to create a system where the camera can focus on a moving object, and in order to do so I need to be able to reference the object in my script(I need to be able to search that object by string or something similar). example code would be much appreciated.

Hey -

The best way to find a specific actor in a level would be to first call GetAllActorsOfClass (UGameplayStatics::GetAllActorsOfClass | Unreal Engine Documentation) which will put all of the actors of the specified class into an array. You can then iterate through the array to find the specific actor that you’re looking for.

To use the GetAllActorsOfClass function you will need to add an include statement for GameplayStatics.h (using the path in the Header Refernece at the bottom of the linked page would work).

Cheers

1 Like

Thank you for the reply, I think I have got it mostly figured out, but I am having trouble calling GetAllActorsOfClass the error is: too few arguments in function call(I feel like this should be an obvious fix but I cant figure it out).

I managed to solve the problem thanks for your help.