Spawn mesh from class of existing mesh

I am running into an issue that so far I can’t solve.

In a nutshell, I’m tracing to a placed static mesh. From there I do Static Mesh > GetClass > Cast To Actor Class > Spawn Actor of Class.

The problem is that Cast To Actor Class never returns Success. So my question is, how can I spawn a static mesh of the same object that was traced to?

Can you please show/explain, what you try to do exactly?
:slight_smile:

Certainly…

In the BP below, Static Mesh and GetClass both appear to equal what they should, but the Cast To Actor Class, which it appears I need to feed into Spawn Actor of Class, never returns Success. My goal here is to be able to spawn another object of whatever this Static Mesh happens to be.

I could suggest to use print string everywhere, to see, what is not working.
Aside that, my BP knowledge is not good enough to understand clear enough, what you are trying there.
What sort of mesh is that, where is the position on the old mesh to spawn fresh one, what happens with old one?
Trying to build a row of meshes?
:slight_smile:

I did that to confirm that everything is working fine up to that last Cast which always fails. Without going into too much detail, the overall goal here is to trace to an instance of foliage, remove the instance, and replace it with a non instanced static mesh in the exact same position and has physics enabled. It works great if I do an explicit comparison against each mesh and then manually set the Spawn Class accordingly, but that is very messy with branches and requires modification every time the foliage meshes are changed. I want to make a drop-in friendly version of it that is able to spawn the static mesh without that step.

Why are you trying to cast to the actor class? Just get the class and plug it straight into the spawn?
Throw some breakpoints on there and see what the state of it is when it hits that branch, seems like it might not have been set in time so its just always hitting false.

The output of the GetClass node (Static Mesh Class) is not compatible with the input of the Spawn Actor of Class node (Actor Class) which is why I was trying to cast it. I have however taken another approach using a blueprint with an unassigned static mesh component. I am now spawning that BP class explicitly, and then setting the mesh, which seems to be working and after thinking more about it, is the way I should have gone in the first place as I will need to attach some logic to the resulting spawn.