Find object in array by display name

Hi all

Is there a simple and effective way to find a specific object in an array by its display name using blueprints.

For example, i have an array of my projectiles in the game and i want to specifically look up individual projectiles by their display name as the game might change the order of the objects when using get all actors of class.

Kind regards.

You might be better served by tags. You can add a tag to each one of the projectiles spawned and then do a GetAllActorsOfClassWithTag.

EDIT: For reference How to tag an actor in Unreal Engine – JAY VERSLUIS

4 Likes

Will definitely give that a go and get back to you

It is a bit slow, but the logic works! Thanks ! :smiley:

If you do have an array of the objects, you can use FindByPredicate if you are fine with C++, otherwise you could replicate the functionality in BP by iterating through each element of the array and comparing its display name to the desired value. Anything that’s GetAllActors related is slow and shouldn’t be used every frame

1 Like

display name I think won’t work in a build.

Object name I think might be build-safe but I’d test it… better is use tag or otherwise identify by some sort of ID. If projectiles are always of the same class you can assign an instance editable variable that is unique to each instance.

This might be of interest as well:
UObjectBase::GetUniqueID | Unreal Engine Documentation

or this:
Guid | Unreal Engine Documentation

1 Like