Having issues in C++ with referencing a blueprint actor who is a child of a created C++ class

Try this:

UBlueprint* DroneBlueprint = FindObject<UBlueprint>(ANY_PACKAGE, L"Blueprint'/Game/Blueprints/Drones/DroneType1_.DroneType1_'");
UClass* TypeOfDrone = DroneBlueprint->StaticClass(); 

Good evening, community! I have read so many differing posts with similar issues and, unfortunately, none of the suggestions seem to be resolving my problem.

I have a parent C++ class called “MSGDronePawn”. This pawn has a child Blueprint, “DroneBaseBP”, which has a child Blueprint, “DroneType1_”. I have another C++ class called “MSGDroneBay” that has a child Blueprint called “MSGDroneBay_BP”.

MSGDroneBay contains a TArray called “DroneLibrary” that is devised of a structure called FDroneType.



I am attempting to set up the DroneLibrary via C++ with 20 elements that will eventually be comprised of various types of drones. For now, I am keeping it simple and only trying to set the type of each element to the same thing; “DroneType1_”. I feel like I am super close to having this work, but no matter what I try, it returns Null for the DroneLibrary[ArrayElement#].DroneClass value. Nothing I try will validly set this, so while I know the elements are being set up correctly and I can modify other known values (the probability value is a simple integer and has no such issues), I can get it to accept my class.

Here are some pictures, if it helps, and I can certainly post more full code snippets if they are needed. Any and all help is greatly appreciated.


Edit: Adding a picture of what it looks like when set through the engine. This is manually adding an element to the TArray and setting the values as needed. Ultimately, I really need to be able to do this through code in order to pull of what I am trying to do with the project.



Thanks for the response and quick attempt. Unfortunately, this didn’t resolve it.
The Misc:: portion doesn’t take and/or compile. Corresponding issues states “name followed by :: must be a class or namespace name.”

I tried a few other close variations, but nothing that produced any different result than I was getting.

This is bumming me out and holding me up from making some serious progress on my project. Anything else you think might work?

If it helps, the actual full path of the BP Class I am trying to reference is:

Many samples of things I have tried had a “C” added at the end of the path, though I am honestly uncertain if that would be needed. Regardless, I have tried it both ways.

Cheers, man. Thanks again!

My bad, Misc::FindObject is my own custom wrapper, I changed original answer

Still doesn’t work, but seems a bit closer.
The TypeOfDrone no longer comes up as Null, but isn’t showing the expected values either. The result was:

  •   TypeOfDrone	0x00000170b2f4c180 (Name=0x00000170b26ff7d8 "Blueprint")	UClass * {UE4Editor-CoreUObject.dll!UClass}

In theory, the value after TypeOfDrone should return DroneType1_

Try just:

FindObject<UBlueprint>(ANY_PACKAGE, L"DroneType1_")

This didn’t work either. Same result as before.

So I worked on this several more hours last night and could never successfully find the exact solution that I wanted.
I am certain that it is possible to do what I was trying to do, but I did find a workaround that will completely meet my needs.

I ended up creating a second TArray that will act as what I initially called the DroneLibrary. The DroneLibrary will now serve as the bank of all possible drones for my project while the new array will hold all of the players current drones. I can easily set the DroneLibrary in the engine and freely save every part of the structure in each element to the new Arrays elements. Tested and works.

Lucas, thanks again for your attempts last night. I am certain you were on the right track, but this works for me.

Hopefully this workaround helps someone else out.

Side note, should I close this thread despite not really finding the “correct” answer quite yet. What’s the etiquette protocol here? :slight_smile: