How do I (re)spawn an instance's static mesh component.

Apologies for the novice question. I feel like I’m missing something fundamental here.

So I have an actor with a static mesh component I want to be able to modify per instance in the editor view. However, when I begin play I want said mesh to despawn. Then I want to send it a spawn message, and have said mesh reappear.

I’ve gotten the spawn logic to work when all the meshes/actors are the same, or otherwise be imprecise (I.E. spawn an unrelated static mesh) but I really need each of these instances to spawn their own bespoke mesh and have that mesh exist in the editor view.

1 Like

So, I’ve determined this method to be impossible.

My alternative method is to simply take the components and push them somewhere else.

And then, when “spawning”, move the specific mesh back to its original position.

Clearly as nature intended.

  • red arrow - create a variable (right click the New Mesh node pin and Promote To Variable), flag it as Instance Editable

Add the same piece of script to the Construction Script:

This will allow you to place actors in the scene and assign each a unique mesh:

Circling back to the very first pic: instead of destroying the component on Begin Play, either set the mesh to none or hide it instead. When interaction (spawn) happens, assign the Static Mesh Component a New Mesh asset using the abovementioned variable.


Alternatively, there is a special property for cases like this:

The Static Mesh Component is Visible while we work in the editor, but Hidden when the game is running. In which case you can assign the meshes to the actors in the scene as you see fit and then the only script you’d need would be:

We merely unhide what was hidden. You can destroy it as you already do.


:medal_sports: for the goofy hack. Thankfully this is not needed here but there are instances where that kind of out of the box thinking is the only way forward, be it due to bugs or engine / BP limitations.

1 Like

Thank you! Exactly the kind of fundamental info I was looking for.

Although, it would appear setting the mesh to “Hidden in game” makes it unable to be toggled/made visible when “spawned”. I had to uncheck that and toggle it on play instead:

Visibility and Hidden are different properties and different nodes - check my screenshot again. Once the Hidden is False, you can use Visibility. Or use just Hidden:

Or:


In short: for Visibility to work, the component cannot be hidden.

Ahh, I see. I thought hidden and visibility were dependent properties. What a strange oddity. Thank you for enlightening me on the subject!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.