How to change a child blueprint from viewport?

I created a master blueprint called BP_coins, and I dragged couple of them to the map, and BP_coin1 2 3 4 5 6 etc. automatically are created as well. Here is my confusion: how can I , let’s say, change BP_coin6’s material? I have experimented a lot and I could only change it in the level blueprint using variable reference. How can I change coin6’s material in other normal blueprint? Every time I try to do so, errors pop out

and this is my Bp_player blueprint

Oh no this is definitely not how it works. Can you explain more how your game works? Do you have a character that collects coins and you want the exact coin that the player collects change the color?

Hi, thx for replying, umm, the purple ball, with the name 123 on its head is my character. yes, the ball will consume the coins when they overlap, but it’s just a tutorial map, basically no main goal. I was imagining, in the future what extent can it be. for example I press a button when controlling the ball, and I can change one of the coin’s material.

Okay so let’s think, the most important thing is to know what you want - on what occasion do you want to change the color of the coin? We need to think about it now so we can implement it. You need to somehow reference the coin in your character (or we might end up using interfaces/dispatchers we will see).

I don’t see a point in pressing a button at a random time and changing the color of which coin exactly? If you want to change the color of the closest coin when you press the button, we can do that. If you want to change the color of all of the coins in a certain radius when you press the button, we can do that. You just need to know what you want so I can help you :slight_smile:

Ok, let’s say, I want to change the color of Coin 6, which I drew an arrow to it, very specific

Okay, so the first step would be for us to create a general function that handles the changing of materials. For that follow the video but simply put.

  1. Create a function in your BP_Coin
  2. Drag the coin mesh from the components panel and add a set material function to it
  3. Add Material input to the function

You can check if the function works for you, if you drag the newely created function into the construction script and try to change materials like I did. If everything works like in the video, let me know and we can move on.

All we just did is that we created a function that will handle the material changing.

Okay, gotta go so I’ll show you the rest. Once your function for changing materials is working, you can change the color probably the simplest unpopular way by doing this.

  1. Add a tag to the coin that you want to change (you can name it whatever you want)
  2. Go to your character and on key pressed call the “get all actors of class with tag”… then for each of those actors found run the function that we have created in the previous step (Do not forget to select material)

Than you can play the game and when you press the key every single actor that has the desired tag will change its material.

If you need anything to explain further, contact me on discord Renkyys#6349

You do not need, script, functions or additional variables for this. Select the actor’s Static Mesh Component in the scene and set its Static Mesh and that mesh’s Material:

Each instance is unique and can be manipulated independently.


I mean, you can do it with script, but there seems to be no reason to do it here. At least as far the question in the initial post goes.

He said that he wants to do it in game with a button click.

EDIT: Or you may be right, when I read the initial question again then this might really be what he was asking

this is exactly what I want, thank you sir, thx for your help ;D