Replacing Mesh with blueprint

Hello everyone,
first of all, I am new to Unreal and I came from Unity, so please don’t be too harsh on my stupidity.

What I am trying to do:

  • Loop through every Mesh in a Map
  • Check if it is not tagged as unchangeable
  • Instantiate a Blueprint “BuildElement” at the position of the mesh
  • Call a function in the Blueprint (called “ReplaceMesh”)
  • Replace an empty Mesh Component in the Blueprint with the Mesh found in the Map
  • destroy the Mesh on the “stage”

My goal is, to prepare a scene (build by an artist) and make the meshes like changeable/ clickable/ selectable, etc.

Looping, Instantiating and function calling is not the problem, but I am struggling with the logic to pass/ copy the mesh into that function.

What I have done so far:

Blueprint GameMode (Looping and comparing - laborious but just a proof of concept):

Imgur

Blueprint of Build Element:

Imgur

My main Problem is, I can’t cast a Static Mesh to a static Mesh Component. And I feel I ve tried every available cast/ get/ set.

Can anyone maybe have a look at this and guid me into a correct / maybe better solution.
Is there maybe an completly other approach or concept I did not think about yet?

Thank you in advance!

Cheers!

Basti

Inside level BP ( for example ):

In the mesh replacement BP:

To get this bit:

you need to pull the pin from Mesh and search for ‘get static mesh component’, then pull from that and look for ‘get static mesh’.

327642-replace.gif

Hi ClockworkOcean,

you are an hero! Works like a charme!
Thank you for your fast and detailed answer. The first part is lookin way better than mine. Thank you for cleaning it up.
In the second part (replacement BP) I thought it would be s.th. like you did, but when i tried to pull from static Mesh Component to Static Mesh it gave me two options. It was the second one which I did not notice it was there.
Thank you again!

Cheers,

Basti