Download

Reference to static mesh in Blueprint Class

Hi :rolleyes:
There is a Blueprint Class his job is change his static mesh always when the level start, that mean the static mesh is always working as a variable, the problem is here:
How can I reference to static mesh in Blueprint Class every time when the static mesh changed ? (for example: to print static mesh name)

best regrads

You get the Static Mesh Component that’s in your blueprint (I assume that’s how you set it up), and do Get Static Mesh on it, then Print String and plug in the static mesh reference into the string (it will automatically spawn a Get Display Name node).

First, Thanks for fast reply :slight_smile:
Ok, I did that, the script read static mesh name, but old one not new one, as I wrote in the top of my topic, the static mesh change to random shape every time level start, as you see in attached images, console print on the screen that static mesh name is Cube.Cube, but the right is Cube.Cone1.Static.Mesh !!

Sorry for bad graphics…

5a97b75c60f1cdb77718387e49bffe01dbc840f2.png
ab13258ea47ebe4e9f2eb2504086dbf40277ec3a.jpeg

Where is that script executed? If it’s on your level BP’s Begin Play, and the script that changes your static meshes is in their own Blueprints, then your Level BP script might be executed before the static mesh Blueprint’s begin play is.

Try adding a 0.1 second delay to the script that gets all your meshes and prints their names and see if its still the old name.

edit: To be honest you should just add the print string logic in the blueprint that holds your static meshes, right after you change the static mesh, that way you circumvent this issue entirely. There’s no point getting all the meshes in your level and then getting their components etc, when you can just have the meshes themselves print their own name.