How to Really make your USTRUCT for the example

If you went with the USTRUCT route, then you ran into the problem of the spawn params being inaccesible.

What you actually want your UStruct to look like is this:


^USTRUCT is marked for blueprint along with UProperties that blueprints can actually read and write

Assides from a unavoidable few crashes you might get from re-compiling your blueprint (this wont pose an ultimate problem), after you do this you can either set default values for a SpawnParams variable, or you can right click on the function node and split the struct. This will split the param into any uproperties you marked that are blueprintReadWrite.


^USTRUCT parameter before splitting the struct into separate definable pins. Alternatively you can break the set note into a make params Node.

USTRUCT(BlueprintType)
struct FSpawnCustomizations
{
	GENERATED_USTRUCT_BODY()
	UPROPERTY(EditAnywhere,BlueprintReadWrite,Category = SpawnParams)
	int32 MinSpawnAmount = 1;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SpawnParams)
	int32 MaxSpawnAmount = 1;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SpawnParams)
	float Radius = 300;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SpawnParams)
	float MinScale = 1; 
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SpawnParams)
	float MaxScale = 1;
};

^Blueprint USTRUCT code. Actually looking back on this, I’m not sure what the Category even does. Better off not including it.

1 Like

Side Note any idea why the bosses don’t work?


^Scale multiplied AI players not moving :frowning:

Using this method I get my struct as an out parameter on my PlaceActors function. How do I change that to make them editable in parameters? SpawnParamsHeader

Just to confirm, is your struct a USTRUCT and are the variables in it UPROPERTIES?

I havn’t really touched unreal or c++ since I posted this stuff (3d modeling instead), but I find it a little odd that you are attempting to modifying the blueprint value instead of using a copy of it. So see what happens by taking that address & tag off if you havnt?

Second thing I see is that its almost as though your GenerateSpawnPositions function is causing blueprints to make the function have return values, although I’m not sure how. This is what makes me wonder if your struct is setup right and if the & operator has anything to do with it, especially since your Struct is not showing up as an input pin in blueprints.

Maybe put a debug print to log before and after PlaceActor so that you know the function is not returning before you get to the for loop/place actor() part.

assides from these also just make sure you are using an up to date compile, and verify by resetting unreal engine, then checking if that made a difference if you havn’t already.

Believe it or not I’ve actually had wierd things happen where resetting unreal didn’t do anything until unreal actually crashed and things mystically were working afterwards. The unstable software that it is :crazy_face:

I don’t know if you got it figured out yet, but your issue is that you pass your FSpawnParameters by ref. If you want to pass it that way via Blueprint you need to write your function like the following:

void PlaceActor(TSubclassOf<AActor> ActorToSpawn, UPARAM(ref) FSpawnParameters& SpawnParameters)

If you’re not modifying your structure in the function, then you can write it that way:

void PlaceActor(TSubclassOf<AActor> ActorToSpawn, const FSpawnParameters& SpawnParameters)

Hope this helps.

Privacy & Terms