Interacting with Level objects in Class blueprint

Hello, I’m new to UE. I’m trying to get the distance between two objects.

I’m using a package called Planes in the Sky: Planes in the Sky in Blueprints - UE Marketplace
It produces airplanes, which unfortunately it seems, are not child objects, based on input parameters, such as how high the planes need to fly, how many, what kind etc.

I have seen the questions/tutorials on how to get the distance between two concrete actors and/or an actor and a simple object, and have been able to reproduce that.

I’m trying to get the distance between my actor (in this case a camera or the platform on which the platform is situated) and the planes that the Planes in the Sky blueprint produces.
So far, I’ve been having difficulty accessing the already created objects/actors in the World view to show up in the Planes in the Sky BP. I’m only able to use the objects/actors when I use the Level BP, not when I’m using the class BP.

I think if I figure out how to access the objects that are in the map I should be able to follow the same examples outlined in How to calculate and print the distance between two objects using BluePrints?

Hey @Jpowwe, welcome to the forums!

So what you’re looking for here is dependent on what you want to do!
Do you want all of the planes and their distances? “GetAllActorsWithTag”! Then give every airplane BP this tag.

Do you want a specific plane’s distance? Try a LineTrace!

Check this stuff out and get back to us! :slight_smile:

Thank you for getting back to me so quickly.
I’m trying to capture simulated data for object recognition/ distance estimation. So It’s not a specific plane whose distance I need. And the planes are “randomly” generated.

Please find attached a screenshot of how the planes are created.

I will try to use the Get All Actors with Tag and get back to you, though it did note that this might create unnecessary lag

OK! So looking at this screenshot, the planes are not individual actors, but spawned static meshes. And I see there is an array there of planes. So.

You can have an inputAction event (or any kind of event) and off of that do a ForEach loop, plugging in that array of Planes. Off of the body line get the location of your camera and your array element, subtract the array element from your camera location, and get the vector length :slight_smile: from there you can do many things with this information. For this example it will just print all of their distances on the screen.

image

Thank you for your response.
Would this be on the a Level blueprint or the Planes blueprint?
My main difficulty has been in finding a way to get direct access to the planes and the external (game level) environment.

Actually I think it’s fixed now! Thank you very much for your help!
It’s been a frustrating couple of weeks.

1 Like

You are very welcome! If you have any other issues, you know where to find us! :slight_smile:
We’re always willing to help out, so don’t be afraid to let us know and ask anything!

1 Like