UE5: How to spawn Dynamic Mesh Component Actor Dynamically?

I’ve created a DynamicMeshComponentActor Blueprint class BP_DynamicCube that will generate a mesh when running the game if I drag it directly into the scene. But spawning this BP_DynamicCube via SpawnActorFromClass will not see the generated mesh, but the IsValid return is success.
I’m guessing it’s because the EventOnRebuildGenaratedMesh written in the BP_DynamicCube isn’t executed when the SpawnActor spawns the BP_DynamicCube, and therefore doesn’t get the TargetMesh. But how do I fix this?




You can get the TargetMesh directly from the Dynamic Mesh component, like this:


Then you probably don’t need to use a timer and RebuildEvent at all.

1 Like

In fact, the eventOnRebuildGeneratedMesh is necessary, only the TargetMesh from it works(Conclusions reached after my tests)

Then the reason I used Timer was that I was trying to call its events/functions in the Blueprint that spawned this DynamicMesh

But I also can’t call its events/functions from the instance I get from the Spawner BP, which is pretty weird

That’s weird, the “Mesh” from GetDynamicMesh is the same thing you get from the Rebuild event. I’ve used that function before and it worked. In fact, I just tested the code and was able to see the cube that was created on the begin play event, so I don’t know why you couldn’t.

This is probably because Generated Dynamic Mesh Actor is an Editor-only class, so you won’t be able to call functions/events from other actors. In fact, I don’t think you should use this class at all. It probably won’t even exist in the packaged game due to that tag.

The Dynamic Mesh Actor class, its parent, is not an Editor-only class, so you should use that instead. It won’t have a Rebuild event though.

(post deleted by author)

Thanks for your help, think i solved some thing!
By using the DynamicMeshActor instead of GeneratedDynaimcMeshActor, i can darg those actors into scene directlly, and they work normally!
Now i’m try to SPAWN those things!



You’re amazing, you seem to have some research on DynamicMesh, can you please look at another question? This is about the performance optimization of dynamic meshes

UE5: Dynamic mesh actor optimize performance