Rama’s Instanced Static Mesh Creator, as BP Nodes!
So I have an immediate solution for the issues people are having with instanced static mesh actors working in packaged games!
I’ve created two BP nodes that let you easily specify which actors you want to convert to Instanced Static Mesh Actors at runtime!
This means that while in the editor, the actors are independent and can be moved around normally (the main advantage I sought to achieve with my ISM editor mode).
But once runtime starts, you can run my BP node to convert all the actors of a specified blueprint/class to instanced static mesh actors!
The other node lets you quickly and easily iterate over all Victory Instanced Static Mesh Actors (VictoryISM) that have been created during runtime!
**Make Dynamic Level Generation Super-Efficient!**
When dynamically generating levels your level unit size has to get smaller the more detailed and varied you want the levels to be. This means that for detailed dynamically generated levels, you usually end up with a very high actor count!
**Well using my two new BP nodes, you can make dynamic level generation super-efficient** by turning 100s of actors sharing the same static mesh asset into a single static mesh!
Remember, the scaling, rotation, and translation of the static meshes can be anything you want!
Two New Advantages For You
The two new advantages of this new system are:
a. You can use my BP nodes with actors that you have created yourself at runtime, such as for dynamically generated levels, MAZES, and such
b. This system will work with packaged games, since the instanced static mesh components do not need to serialize properly (as they currently dont seem to be doing). The serialization/cooking process becomes irrelevant since the actors are only converted to Instanced Static Mesh Actors at level start!
**Use of TMap, One Instanced Static Mesh Per Static Mesh Asset**
I use a C++ TMap to group all the actors of the class you specify, and create as many instanced static mesh actors as are required.
Each Instanced Static Mesh Actor can only represent actors that **share the same static mesh asset**, so I group all the found actors by their static mesh asset!
Here's the code where I do this!
**//I want one array of actors for each unique static mesh asset! -Rama**
TMap< UStaticMesh*,TArray<AActor*> > VictoryISMMap;
**//Note the ActorClass filter on the Actor Iterator! -Rama**
for (TActorIterator<AActor> Itr(World, ActorClass); Itr; ++Itr)
**//Get Static Mesh Component!**
UStaticMeshComponent* Comp = Itr->FindComponentByClass<UStaticMeshComponent>();
**//Add Key if not present!**
VictoryISMMap[Comp->StaticMesh].Empty(); //ensure array is properly initialized
**//Add the actor!**
Then, I loop over the TMap, and access the Array of actors that I created that all share the same Static Mesh asset, and then turn the whole lot of them into a single Instanced Static Mesh Actor!
**//For each Static Mesh Asset in the Victory ISM Map**
for (TMap< UStaticMesh*,TArray<AActor*> >::TIterator It(VictoryISMMap); It; ++It)
**//Get the Actor Array for this particular Static Mesh Asset!**
TArray<AActor*>& ActorArray = It.Value();
if(ActorArray.Num() < 1) continue;
**//Get the Root**
UStaticMeshComponent* RootSMC = ActorArray->FindComponentByClass<UStaticMeshComponent>();
for(AActor* Each : ActorArray)
**//Create Victory ISM**
SpawnInfo.bNoCollisionFail = true; //always create!
SpawnInfo.bDeferConstruction = false;
AVictoryISM* NewISM = World->SpawnActor<AVictoryISM>(
const int32 MatTotal = RootSMC->GetNumMaterials();
for(int32 v = 0; v < MatTotal; v++)
for(const FTransform& Each : WorldTransforms)
**//Add new ISM!**
Easy to Edit, High Performance at Runtime!
The result of using my BP nodes to turn all actors of a certain class to instanced static mesh actors is that you can now maintain easy editing of the actors while in the editor, and during game-time still gain the performance advantages of converting a large number of actors that share the same static mesh asset into a single actor!
You can also now convert the large quantity of actors in dynamically generated levels into high performance instanced static mesh actors!
[FONT=Comic Sans MS]