NO DISTINCTION BETWEEN PREVIEW MESH AND IN-GAME MESH

Hello ev! I have a problem with my bp that spawns interiors in reference to the rooms, when I added the meshes in this bp I didn’t see their previews for some reason, so I thought of using an add instance node in the construction script of the same and now I see them before the spawn to have a clearer idea. The problem is that unreal doesn’t distinguish between the meshes that must actually spawn in game and those that must only show me in the viewport. So the mesh previews are spawned and forced on the coordinates 0,0,0. I tried with hidden in game on the bp and on the single elements, I tried is editor only, I also tried using a clear/destroy in the script, but it doesn’t work. That is, every change I make on the mesh previews is then also made on the mesh to spawn. The absurd thing is that all this didn’t happen before the last interior added. But I can’t find the connection between this mesh and this problem. What do you think? What do you suggest?
Thank you so much!


1 Like

If you want to use the construction script to show you where the meshes will spawn, but then also spawn them during the game, you’ll need to have a bool to tell you if you need to run construction or not. Just set it to false before you run the game.

Or, you can place them in construction, but keep references so you can destroy them on begin play, and then spawn the others.

Usually people place meshes in construction, or at run time. If you want both, then you do need to write some code to compensate.

1 Like

Thanks for the reply! I wanted to use the script only to have a spoiler of the meshes that then in begin play, I will spawn via dispatcher. I tried with a branch and a has priority, but then when the previews were deactivated, also the meshes to spawn in game were. However I’m not sure how I can destroy only those in the script. I tried to make them variables, but then in the nodes I only had options to remove all instances and therefore also those that should spawn. That is, it’s as if by deactivating the script with beginplay, the spawner no longer has references and therefore spawns don’t occur.
@ClockworkOcean

1 Like

Don’t use ‘add instance’, that’s for instanced static meshes. I assume you actually want static mesh components. Then you can collect the references with

Then later

1 Like

I wanted to use instanced static mesh for spawns mostly, because multiple identical meshes can spawn in my map and I wanted to reduce calls to improve performance. That is, now I have a doubt , if I set the mesh for the preview as a static mesh, then after removing it, do I have the way to set all the other spawns as instanced of that same mesh? Otherwise if it is not possible or not efficient, I could add other bp to call the instanced, and use the viewport of this bp just to have a visual spoiler…I thought. @ClockworkOcean

1 Like

Instancing isn’t really worth bothering with unless you have a large number of similar meshes. Say, more than 100 ( very rough amount ).

Spawning doesn’t give you instances, just adding instances gives you instances, which you’re doing in the construction script.

1 Like

I know in fact I wanted to spawn some instances because I already know that many can spawn and they are optimized, very lowpoly. But the point is that I need to exclude what I see in the bp viewport, from the in-game spawns. But as already said if I manipulate those preview meshes, all the spawns are affected. So now I will try somehow to differentiate them between script and event graph.

1 Like

Ok. At your suggestion in the script, I added some nodes that I thought in the graph. The meaning was, from the array created to contain the instances added in the script, for each element, set as a variable, take its transform and compare it with that of the default scene root (0,0,0) if they match, destroy the component. Something has changed, that is, the problem is fixed but halfway. Because now, what happens, the mesh that no longer spawns at point 0, spawns perfectly in all the other points where it should do so, while the other mesh that still spawns at point 0, no longer spawns in the other rooms. Also at the end of the simulation, I have an error accessing an array element. What do you think? It’s a bit strange.


@ClockworkOcean



I solved it without new arrays, and destroy/remove. I introduced add instance between spawn and socket snap, so first it goes to 0 and then snaps to the appropriate transform and it seems to work. Now on 0,0,0 there are no anomalous meshes and each instance recognizes its own room correctly. I had tried with add instance immediately in begin play but it gave the same problem, despite the array and the remove command. Simply keeping the nodes in the script disconnected when I go into simulation. I’ll use them as a visual spoiler only when I’m in editor. I don’t have any better solutions at the moment.

Thanks anyway! @ClockworkOcean

1 Like

Very good :slight_smile:

1 Like