GeneratedDynamicMeshActor vs. DynamicMeshActor

Most of the tutorials/videos (e.g. https://www.youtube.com/c/RyanSchmidtEpic) show making a blueprint with GeneratedDynamicMeshActor.

GeneratedDynamicMeshActor provides an “Event on Rebuild Generated Mesh” which is quite handy, but not really needed for my purpose. It also has the side effect that in other blueprints, even if I have a blueprint reference to the GeneratedDynamicMeshActor, I can not call its functions. I do not understand that limitation. While I can work around this using Event Dispatachers/Bind/UnBind, I would prefer not to.

On the other hand, DynamicMeshActor does allow other blueprints to call its functions. But I need an equivalent of “Event on Rebuild Generated Mesh” since the user is allowed to change some parameters (in game, not in Editor) which then causes the mesh to change.

I created a Custom Event and used Get Dynamic Mesh from Dynamic Mesh Component for what was called “Target Mesh” in the “Event on Rebuild Generated Mesh”.

The problem with that, is when user changes a parameter that constructs the mesh, the new event has both the old mesh and the newly constructed mesh joined (i.e. since there is all ‘Add …’ nodes). I do not want the old Dynamic Mesh. I need to clear the current Dynamic Mesh before updating.

So, in other words, I would like to have a DynamicMeshActor behave like GeneratedDynamicMeshActor, but I don’t see how to reset the Dynamic Mesh so I can rebuild the mesh from a clean mesh.

Hope that makes sense and there is a simple answer.

TIA

1 Like

I found one workaround. When you want to rebuild the mesh, get a new Dynamic Mesh from Allocate Compute Mesh and use that to construct the new mesh and then use that as input to Set Dynamic Mesh from Dynamic Mesh Component.

One could also get a new Dynamic Mesh from Construct Object from Class, but I expect that will cause memory problems eventually.

What is the recommended way?

there is a ‘Reset’ node (Reset | Unreal Engine Documentation thanks to Geometry Script Tools Meshes Not Appearing In Packaged Builds. Any Solutions? - #3 by alexanderlind5). so when you want to regenerate the mesh, first Get Dynamic Mesh from Dynamic Mesh Component and run that into Reset and then use that dynamic mesh to regenerate.

Happiness. Hopefully this is the correct way!