Can't spawn static mesh from blueprint

I can’t seem to spawn a StaticMeshActor from my blueprint.

When I start the level nothing has spawned and after I close PIE it gives me a warning:
“Calling SetStaticMesh on ‘None’ but Mobility is Static”

All I’m trying to do is spawn a plane to act as a 3D crosshair that I can attach to my character, but no luck getting passed the spawning phase :frowning:

1 Like

ok first off you are trying to spawn something that hasn’t been set yet.

You need to SET what you want to spawn BEFORE you spawn it.

Hello! Thanks for responding :slight_smile:
I’m sorry I guess I don’t quite understand. How can I set something before it exists?

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.

you’re right, now i am curious, too :slight_smile:

Doesn’t Set Static Mesh simply change which 3D mesh the StaticMeshActor renders? I didn’t think it created anything at all.

I tried your suggestion though and the PIE came back with errors.

“Accessed None ‘Cursor Plane’ from node Construction Script in blueprint BP_PlayerCharacter”

My understanding was that I need to spawn a StaticMeshActor, then tell it which mesh to use using ‘Set Static Mesh’.

Here’s what I changed it to:

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 tried what you suggested and it worked :slight_smile:

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! :smiley:

well yes you can spawn staticmesh actors.

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

1 Like

Cool solution! I never realized you could edit the properties of of the component just by clicking on the node. Thanks!