How do I get a C++ function into a BluePrint Level


 #pragma once
    #include "CoreMinimal.h"
    #include "UObject/NoExportTypes.h"
    #include "Core/Public/Math/Vector.h"
    #include "Core/Public/Math/UnrealMathUtility.h"
    #include "MyGame/MyGameEnums.h"
    #include "MyGame/MyGameStructs.h"
    #include <random>
    #include "Containers/Array.h"
    #include "StarArrayGen.generated.h"
    class MYGAME_API UStarArrayGen : public UObject
    	UFUNCTION(BlueprintCallable, Category = "Star Generation")
    		TArray<FVector> GetStar();
    	std::mt19937 mtRand;
    	float coreRatio = 0.15;
    	float minStarDistance = 30;
    	float rotationStrength = 300;
    	float gravity = 10;
    	float galaxySize = 1600;
    	float armCount = 2;
    	float armSpread = 0.4;
    	FVector NextVec(float min, float max);


#include "StarArrayGen.h"


TArray<FVector> UStarArrayGen::GetStar()
	TArray<FVector> NewStar;

	 int counter = 0;
	while (counter++ < 20)
		FVector v = NextVec(-1, 1);


	return NewStar;

FVector UStarArrayGen::NextVec(float min, float max)
	std::uniform_real_distribution<> distr(min, max);
	return FVector(distr(mtRand), distr(mtRand), 0);

Okay, my problem: I am absolutely new to C++. (My native programming language is Perl.) I was brought in after the previous C++ coder on this project disappeared. I need to bring ‘TArray GetStar();’ into a level blueprint.

The problem - if I make that function static, it can’t use any of the higher math functions that are needed.
If I don’t make it static, the level blueprint wants a target and I’m not even sure what that means except that the blueprint wants something.

Level blueprint needs reference to your object (target). You can use GetAllActorsOfClass (Do not use it in Tick method!) to get all the stars. This will return array of the objects you searched for. Then, you can do a for loop and call method on every instance found in array returned by GetAllActorsOfClass.

Okay - I think I understand - I need to find or designate the parent actor as the target. (In this case, the array is being generated so stars can be spawned into the level. But there has to be a parent.)

I was able to locate the parent actor and added the ‘create array of vectors’ code to that. Now it works. Thanks.