I have tried to spawn a custom made Procedural Foliage Spawner using C++ using SpawnActor. There I have found SpawnActor cannot be used since ProceduralFoliageSpawner is a UObject.
Then I was able to spawn a AProceduralFOliageVolume, which is an AVolume (which is an AActor) using SpawnActor in Unreal Viewport using the following code.And it worked.
But when I spawn the Procedural Foliage Volume, it doesn’t have the bounding box and does not show one even if I select from Brush Shape. I have also selected the Foliage spawner for the volume and set scaling to the volume.
Hello! SpawnActor can be used only with Actors (Naming convention - their names begin with A). UObjects (Naming convention - their names begin with U) can be created with this
auto spawner = NewObject<UProceduralFoliageSpawner>(outer, name);
In fact you can create it just before usage and then destroy (nullify all pointers) if spawning activity is just one moment thing. But also you can keep it in some UProp if want it to be valid for long time
Thank you very much. But when I try to spawn in in the world programmatically I do not get the bound-box (Even selecting Box brush after spawning). Therefore I tried to find the bounds and printing them and they both are 0.
Hi @Kehel18 , Thank you. I looked into component bounds and couldn’t find a setter but there was just a getter. Then I tried to access Level Bounds class and found this comment in …/Editor/LevelBounds.h
/**
*
* Defines level bounds
* Updates bounding box automatically based on actors transformation changes or holds fixed user defined bounding box
* Uses only actors where AActor::IsLevelBoundsRelevant() == true
*/
Further finding AProceduralFoliageVolume doesn’t have it defined.
AVolume, which is the super class for AProceduralFoliageVolume has the levelbounds set to false. Yet the procedural volume in Unreal editor does have bounds.
I was wondering how I can set the level bounds programmatically as it’s visible in the Procedural Foliage Volume similar to that we use in editor mode.