just reverse the nodes…
these blue nodes are like pointers… first they point to nothing…
with set static mesh you create in this instance a “shared_primitive…”
then you point your object pointer to that new object…
but now it is just in your memory… not in your scene…
with “spawn actor” you are creating an actor with that mesh and spawn it into your scene…
Ok so you have a staticmesh which you need to create (SET) what kind it is. Then you spawn it into the level. The static mesh has no idea what you want when you are trying to spawn it as you haven’t told it what kind it is. The nodes fire off in order. So you are telling it right now to spawn a staticmesh then after that you told it what kind. You have the right idea just wrong ordering.
I think you and Dave4723 are suggesting the same thing? I responded to him below with what I think you were suggesting as well. Set Static Mesh simply tells a StaticMeshActor which mesh to use, it doesn’t create anything. I could be wrong but I’m pretty sure I need to spawn the actor first and then tell it which mesh to use.
One other thing is I screwed up and said that the PIE gives me an error, it’s actually just a warning. Not sure if that helps though. I will edit the original post.
ok so i looked around in the code a little bit and i think the problem is that blueprint doesn’t provide a possibility to compose a new static mesh actor at runtime…
you could make a blueprintclass and spawn that… only the composing at runtime seems to be the problem
I made a blueprint of my cursor plane and selected it in the Spawn node. That is weird that you can’t spawn a StaticMeshActor from blueprint though. Anyways, thanks for your help!
What you could do to make it easier unless you plan on having different actors spawn is in the COMPONENTS tab select your Staticmesh actor( I assume you didn’t rename it) and the scroll down in the details and you should see the mesh says NONE put your mesh choice in there then you don’t have to set anything anywhere else as you have now designated that the staticmesh actor IS the plane.
FWIW, this is what I found worked best and most simply:
Create a blueprint called “BP_SingleMesh” with a single mesh in it. In your blueprint (where you want to spawn a simple mesh into the blueprint), use a SpawnActor with your BP_SingleMesh, then use a “set static mesh” node.
So “SpawnActor(BP_Blueprint)” ===> SetStaticMesh(TheMeshYouWant)
This seems a bit wasteful if you need to spawn many meshes into the scene, but basically it came down to “wrap it in blueprints and spawn normally” for me.
So i ran into this problem and have a solution that may be helpful to anyone else that ends up here.
do not spawn a static mesh at runtime and expect to move it around, you cant ( thats why you are here)
instead spawn a generic actor, then add a static mesh component to that actor
For anyone still struggling - here is a simple answer and solution. If you try to use the Add Static Mesh Component node to add a mesh to the scene using Blueprint code you must use the Set Static Mesh component when you call that node in Begin Play for example. I first tried to spawn a wall segment (called SM_V2_Wall1) using only Add Static Mesh (and selecting my mesh in the Details panel) and it worked fine inside the Blueprint in design time. But if I called that same function from Begin Play they just do not appear when I press play. I hope the following screenshot helps.
I now found out that you can use this combination of nodes to “spawns” a BP as a component of another BP. The big benifit of this is that it works in the construction script too.
Add Child Actor Component → Set Child Actor Class
Remember to select your BP in the In Class field!
Hope this helps people! Happy Unrealing!