Merged Actor SM not applied to Spawned Actor

As the title describes, I am generating a Merged actor from selected actors that are then added to a Spawned Actor, which contains in this case HISM component.
I apply this merged actors output SM to the component, however it just ends up spawning a blank Actor, and doesn’t populate the component at all.

When then manually adding it to the component (taking the merged actor output SM from the Content browser), it accepts it, but doesn’t actually add it to the level any idea why?

The blueprint:

When debugging this now that I am home, it lets me know that it fails to set the static mesh for the component.
I also changed the blueprint to have a HISM component without having to create it on the fly, just in case, but it didnt change anything.

The only thing that I can think off why this would be the case is that it gives me the message that its still preparing the Static mesh, and therefore I think its not done generating/saving the SM but already passes along the reference and therefore cant assign it to the component?

Strange! In their source code they seem to do it ok (bSpawnMergedActor=true):

		OutMergedActor->GetStaticMeshComponent()->SetStaticMesh(MergedMesh);
		OutMergedActor->SetActorLabel(MergeOptions.NewActorLabel);
		AllActors[0]->GetWorld()->UpdateCullDistanceVolumes(OutMergedActor, OutMergedActor->GetStaticMeshComponent());

What are your parameters for the merge? Are there any other hints in the Log?
Can you test by merging it with one function/button and then adding the HISM with another?

When I select that bool flag for the merge settings, it does spawn a SEPARATE static mesh actor just fine, and if I actually create one first and then give it the generated mesh it also works without issues.
But if I take the blueprint with the HISM component, it takes it (it actually accepts it and displays that it is the used static mesh for the component), but never actually spawns/creates/adds it in the level.


The Merge parameters are pretty basic, only thing I told it to do was include all LOD’s since I need those.
Then there is the Base Package Name, I simply feed it the current levels path since I want to save it in an easy to find location. (well I probably gave it the reference to the level ie. MyLevel.MyLevel based on the logs instead but it still creates it just fine, and the SM is passed by reference when created anyways)

This is the log I get for the above code is this (replaced paths to reduce size):

LogBlueprintUserMessages: [EW_MultiHISM_C_0] StaticMeshActor_5083
LogBlueprintUserMessages: [EW_MultiHISM_C_0] StaticMeshActor_5071
LogBlueprintUserMessages: [EW_MultiHISM_C_0] StaticMeshActor_5373
LogEditorAssetSubsystem: Error: GetPathNameForLoadedAsset failed: The object 'PersistentLevel' is not an asset.
LogMeshMerging: Warning: Cannot create StaticMesh //LEVEL_PATH.LEVEL_NAME
An object with the same fully qualified name but a different class already exists.
    Existing Object: World //LEVEL_PATH...
The merged mesh will be named //LEVEL_PATH...
LogStaticMesh: Display: Building static mesh *LEVEL_NAME*_0...
LogScript: Warning: Accessed None trying to read property CallFunc_MergeStaticMeshActors_OutMergedActor
    EW_MultiHISM_C /*LEVEL_PATH...*:EW_MultiHISM_C_0
    Function /TOOL_PATH/EW_MultiHISM.EW_MultiHISM_C:Create Multi HISM Actor:0825
LogScript: Warning: Accessed None
    EW_MultiHISM_C /*LEVEL_PATH...*:EW_MultiHISM_C_0
    Function /TOOL_PATH/EW_MultiHISM.EW_MultiHISM_C:Create Multi HISM Actor:083A
LogBlueprintUserMessages: [EW_MultiHISM_C_0] Failed to set Static Mesh
LogStaticMesh: Built static mesh [0.77s] /*LEVEL_NAME*_0.*LEVEL_NAME*_0

As a matter of fact already have thought of using a second button for that as well but haven’t come around to doing that just yet, but I will try that now.

Interesting - maybe try deleting the static mesh first?

	IPlatformFile& pf=FPlatformFileManager::Get().GetPlatformFile();
	if(pf.FileExists(*packageName)) {
		bool b=pf.DeleteFile(*packageName);
	}

Wdm? I’m not exactly sure how that helps?
But if your thinking the generated SM is the problem, I have every time I tested it deleted the previously used SM. If you are thinking based on the LOG that the asset already exists.

As a mater of fact I restarted the entire editor before getting this log since I had to force delete the Meshes even if the actor is already deleted.

1 Like

Is there maybe any way to make the editor wait with the execution of the rest of the code until the Generated Mesh is saved & ready to use?
I tried using editor delay / delay but it didnt seem to do anything, and it didnt even seem to affect it, since I added like 5sec delay but it never lasted this long to actually execute the code and give me an error log that I put after Set Static Mesh.

Enable Tick on your actor and create an integer variable, instead of executing the code, just set the variable to something like 300.
Then in your tick, test that variable for greater than 0, decrement until 0 and run that code when it’s zero if it was initially not zero…

Edit: I’ve not actually tried using tick with utility blueprints - you may need to use:

1 Like

Hmm, alright, its not the timing.
I generated the mesh on its own and then added it to a manually placed actor of the same class. It did the same thing where it accepted it but never spawned it.
The same with any normal static mesh.
Am I missing something, how do you setup a HISM component to take a static mesh :sweat_smile:

Ill try that as well. Just in case.

It really should be that simple - it must be something to do with the returned actor and the fact it hasn’t been spawned. As it works if you do spawn it, what about doing that, then just destroying the spawned actor afterwards?

Well no, as I said, if I create it separately and/or use a completely separate static mesh that already exists in the project asset registry (aka is imported), it still doesn’t display it.
I went into the blueprint, I added a random static mesh to 3 components (SM, ISM, HISM).
And the only one that actually showed me this unrelated to me SM, is the SM Component.
The others didn’t even display it, neither in blueprint editor or the level editor.

So I must be REALLY doing something wrong for this not to be working…

I’m running out of ideas - I’ve done similar things in c++ plugins but not with editor utility blueprints.

What about a simple blueprint that just does this on a button press?

Well, that does assign the mesh I give it, even the merged one.
But it just doesn’t display anything, no mesh to be found anywhere, just as when I manually drag the merged mesh into it.
Same with when I use the previously used unrelated random static mesh.

Im also running out of any ideas as to what this could be caused by.

With the HISMC - that doesn’t ever show anything by default (or the ISMC) - the SetStaticMesh just tells it which mesh to use as the source - you’ll still need to “AddInstance”:

1 Like

Very good call! I can now indeed see any static mesh given to the HISM component.
However, still unable to set the generated SM mid blueprint- but if I manually add it to the component it assigns just fine.

Even when I create the instance first.

Can you set it mid-blueprint to an existing SM rather than the generated one now?

Yes if I use any pre-existing mesh it works.

right - maybe the two button method then?

Probably will have to do that, will need to figure out if there is some way to automate it, but well… ill update if I find a solution to it.
At least now I can confirm that I still have my sanity because I now WILL see it when it works in contrast to before.

1 Like