# Dynamic Material Instancing through another blueprint?

**URL:** <https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137>\
**Category:** Blueprint\
**Tags:** communication, unreal-engine, question\
**Created:** [June 20, 2021, 3:05pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137 "2021-06-20T15:05:03Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![NUKETheWay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nuketheway/32/489447_2.png) [@NUKETheWay](https://forums.unrealengine.com/u/NUKETheWay)\
**Post date:** [June 20, 2021, 3:05pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/1 "2021-06-20T15:05:03Z")

</div>

Hello

I have two blueprints.

One has hexagon Mesh with BaseMaterial

Another is hex tile generator Blueprint for generating hexagon BP. The tiling script is a function in hextile\_BP

Also HexTile\_BP is added in world outliner

Once event begin play called it creates hexagon tiles.

Now How do I create dynamic material instance on all those hexagon mesh generated by hexTile\_BP and how to change access/edit those instances in blueprints.

I can do most of it but, I am struggling with generating material instaces for each hexagon and then communicating their properties between both BP

Below images shows HexTileGenrator\_BP

And HexMesh\_BP has only hexagon mesh.

I was following this tutorial

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/7/a/b7a13cc4e59d5262e5e58b879ed44b829451c0b8.jpeg "Intro to Materials: Dynamic Material Instances cont. | 10 | v4.0 Tutorial Series | Unreal Engine") ](https://www.youtube.com/watch?v=i2XmTbfIJ3s)

It is not that hard for single mesh. But I don’t know how to do it for multiples meshes.

 ![341910-annotation-2021-06-20-203012.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/6/a/e6aff9c54cab10809dc1ccd3c26e9e342dca5ba1.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 20, 2021, 3:38pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/2 "2021-06-20T15:38:38Z")

</div>

> I can do most of it but, I am  
> struggling with generating material  
> instaces for each hexagon and then  
> communicating their properties between  
> both BP

Do it in the Construction Script of the HexMeshBP and assign the material to a variable.

 ![341921-screenshot-8.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/6/b/56b3e8cb9f836d51fcd3b8f07b0900baa11e470c.png)

> then communicating their properties  
> between both BP

How to communicate will depend on how you want to interact with the hexes and what needs communicating. Can you provide an example?

If you want the dynamically spawned Hexes talked back at the HexTilingBP, Event Dispatchers would work really well.

---

<div class="post-metadata">

**Author:** ![NUKETheWay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nuketheway/32/489447_2.png) [@NUKETheWay](https://forums.unrealengine.com/u/NUKETheWay)\
**Post date:** [June 20, 2021, 3:40pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/3 "2021-06-20T15:40:13Z")

</div>

I did it by adding function “set material to Mesh” then feed the Dynamic material to it. But in tutorial video he didn’t do that then how his script working? He never applied Dynamic Material to chair cushion. He simply created dynamic instance of chair material and changed its color using variable dynamic material. He didn’t apply dynamic material to chair cushion. But I had to. Why?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 20, 2021, 3:59pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/4 "2021-06-20T15:59:23Z")

</div>

> I did it by adding function “set  
> material to Mesh” then feed the  
> Dynamic material to it.

It’s fine, too. What I suggested automates it.

> He didn’t apply dynamic material to  
> chair cushion.

The chair is a single mesh, the cushion is part of it:

> **[Using Texture Masks](https://docs.unrealengine.com/4.26/en-US/RenderingAndGraphics/Materials/HowTo/Masking/)**
>
> Guide for using Texture Masking in your Materials.

If you have proper masks and complex enough materials, you can get away with a single dynamic material to adjust multiple areas of the same mesh:

 ![341922-screenshot-10.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/4/8/048b577cff65171b9338336e7c8f8c8f73a1334e.jpeg)

ColorSeats seem to be it here.

---

<div class="post-metadata">

**Author:** ![NUKETheWay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nuketheway/32/489447_2.png) [@NUKETheWay](https://forums.unrealengine.com/u/NUKETheWay)\
**Post date:** [June 21, 2021, 4:48pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/5 "2021-06-21T16:48:07Z")

</div>

I set my dynamic material random color. Now How can I setup event dispatcher for communicating each HexMesh’s instance’s color with each other in HexTiling\_BP Any basic quick example or tutorial link?  
I want to be able get values of those color on click or tap and perform some math on them later on with respect to each other.  
Thank you

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 21, 2021, 4:54pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/6 "2021-06-21T16:54:46Z")

</div>

- in the Hex Actor:

 ![341979-hexmid.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/f/8/1f8be17c884efa3731b4aa96c800aa3b446c4eb1.png)

- we’re clicking the hexes, which fetches color from the material instance and calls the dispatcher

 ![341980-hexed.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/e/0/7e0500ec3a97fec0ccf2d645440d879556f329c6.png)

- in the spawner:

 ![341981-spawner.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/9/f/19fde0b1ffbcb032086a1c37d9dbfd311e047fc0.png)

Ensure the Parameter Names match what’s in the material. Every time the Hex actor is clicked, this event will be executed. When you drag a wire from the Return Value pin, search for ‘assign’ and then dispatcher name - this will _automagically_ create the event with the correct signature.

---

<div class="post-metadata">

**Author:** ![NUKETheWay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nuketheway/32/489447_2.png) [@NUKETheWay](https://forums.unrealengine.com/u/NUKETheWay)\
**Post date:** [June 21, 2021, 5:02pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/7 "2021-06-21T17:02:21Z")

</div>

Thank You Very Much. You saved my week’s struggling in few minutes

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 21, 2021, 5:05pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/8 "2021-06-21T17:05:48Z")

</div>

I have a soft spot for hexes 😉

Good luck with the rest!

---

<div class="post-metadata">

**Author:** ![NUKETheWay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nuketheway/32/489447_2.png) [@NUKETheWay](https://forums.unrealengine.com/u/NUKETheWay)\
**Post date:** [June 23, 2021, 7:32am UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/9 "2021-06-23T07:32:35Z")

</div>

Hello My hex generator is a function. I am unable to create custom event (SendMyColor\_Event\_0) in there. What to do in such case?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 23, 2021, 7:48am UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/10 "2021-06-23T07:48:36Z")

</div>

You have two options:

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/1/a/d1a36adefb9a80e41bc952fdc0d7bdac7c6b917b.gif)](https://gyazo.com/f4c98c19b74795fa06b19b2445bbf4b1)

![342185-screenshot-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/e/b/beb530c7807b315cd8f7f75c11613d679d1a7846.png)

Or:

 ![342186-screenshot-3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/9/6/8968dbb3fe0a7b16020254bde6f76bc6c8e93f56.png)

This way you can bind the dispatcher call to another event elsewhere (outside the function) or even another function - super useful and it make it neater, with fewer wires snaking around.

Important: you must ensure the signature on the event / function:

![342187-screenshot-4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/9/0/f90d1e685a0b53b2ad027b17d7c92b7d50aa9ff9.png)

Is identical to the one on the Event Dispatcher:

 ![342188-screenshot-5.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/a/8/3a8c8166e870e13f0eb449dfb7635d70cbe26312.png)

Those two are not matching at all, for example! You can automate it by choosing a matching function / event from the list.

---

<div class="post-metadata">

**Author:** ![NUKETheWay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nuketheway/32/489447_2.png) [@NUKETheWay](https://forums.unrealengine.com/u/NUKETheWay)\
**Post date:** [June 23, 2021, 9:25am UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/11 "2021-06-23T09:25:25Z")

</div>

I am not properly getting answer. Please help.  
First in which blueprint I have to create this event.  
Also we have events for mesh in details pan. and there is on clicked event with same variables"Touched Component/ Button pressed" Is this a same thing?

![342187-screenshot-4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/9/0/f90d1e685a0b53b2ad027b17d7c92b7d50aa9ff9.png)

 ![342201-annotation-2021-06-23-144329.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/c/1/bc170afe9e530b58d82f28fbbf1980419ebc65ec.png)

Because above I am not getting any funtions/events in create event.

You dont have to go through blueprinting all of these.

I am aware of blueprint interface very well as I am spending lot of time seeing this.

I just don’t get how the functions events connects to each other and some doesn’t

Please give me quick steps to do in few lines or point me to the tutorial where I can learn all this properly this time. ThankYou

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 23, 2021, 11:04am UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/12 "2021-06-23T11:04:39Z")

</div>

> Please help. First in which blueprint  
> I have to create this event.

In Hex Tiling - called Hex Generator in my screenshots.

> Please give me quick steps to do in  
> few lines or point me to the tutorial  
> where I can learn all this properly  
> this time.

There really is not much more to it. You can do this to automate it:

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/d/77df08d926f33d81912332ee9db2a5fac6f2b095.gif)](https://gyazo.com/e1ec804f0a9cb4f69a8f08bea84ac843)

And then cut / paste this node outside of the function. Make sure you Compile.

---

<div class="post-metadata">

**Author:** ![NUKETheWay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nuketheway/32/489447_2.png) [@NUKETheWay](https://forums.unrealengine.com/u/NUKETheWay)\
**Post date:** [June 23, 2021, 2:50pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/13 "2021-06-23T14:50:49Z")

</div>

![342233-annotation-2021-06-23-201834.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/d/f/ddfbd4ae8c291fa3d5762987f435c99b585f5853.png)

In which blueprint (HexTiling/HexMesh) I have to add event dispatcher?

I am not understanding what this is doing. Where can I learn all this?  
I have been reading all this [Creating Dispatcher Events | Unreal Engine Documentation](https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScripting/Blueprints/UserGuide/EventDispatcher/CreatingEvents/)

Since morning. It doesn’t explain how to work with variables/Actors. Is there better way to learn?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 23, 2021, 4:40pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/14 "2021-06-23T16:40:53Z")

</div>

You can’t have a custom event inside a function. As I said:

> And then cut / paste this node outside  
> of the function.

Place the event outside of this function. Cut and paste it from the Function to the Event Graph. Ctrl+X on the node and Ctrl+V in the graph.

> In which blueprint (HexTiling/HexMesh)  
> I have to add event dispatcher?

In the Hex Mesh. But if you’re using just Click, you already have it:

 ![342239-screenshot-7.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/4/2/34277c9b118a45a7eb9a9bc1a74e1f8ef7a44207.jpeg)

Actors come with a lot dispatchers already, you can add your own to send custom data.

* * *

You can also create this event manually if you prefer, but adding signatures is a hassle.

---

<div class="post-metadata">

**Author:** ![NUKETheWay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nuketheway/32/489447_2.png) [@NUKETheWay](https://forums.unrealengine.com/u/NUKETheWay)\
**Post date:** [June 23, 2021, 5:32pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/15 "2021-06-23T17:32:38Z")

</div>

Thanks for this. Now I understood how it works. I cut pasted it as you said. First in HexMesh\_BP didnt work. It was unable to find that custom event.  
Then I redo the same again. But this time I pasted that custom event in HexTiling\_BP. Got no error.  
But it still didnt print the actor name.

 ![342258-annotation-2021-06-23-225312.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/0/a/20a82101822d9d212287554ee40930f852bdc6b4.png)

Do I have to call that custom event from somewhere ? But I already bind it to On Clicked Dispatcher.  
Do I have to assign variable to “Button Pressed”. I was only able attached setter to it and assign left click. Didnt work!

---

<div class="post-metadata">

**Author:** ![NUKETheWay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nuketheway/32/489447_2.png) [@NUKETheWay](https://forums.unrealengine.com/u/NUKETheWay)\
**Post date:** [June 23, 2021, 5:43pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/16 "2021-06-23T17:43:07Z")

</div>

Wait its working

---

<div class="post-metadata">

**Author:** ![NUKETheWay](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nuketheway/32/489447_2.png) [@NUKETheWay](https://forums.unrealengine.com/u/NUKETheWay)\
**Post date:** [June 23, 2021, 5:45pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/17 "2021-06-23T17:45:24Z")

</div>

I bind it to On Input Touch Begin. Few days ago I set mouse cursor to be used as touch. Does this makes ON Clicked event stop working?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 23, 2021, 5:57pm UTC](https://forums.unrealengine.com/t/dynamic-material-instancing-through-another-blueprint/485137/18 "2021-06-23T17:57:13Z")

</div>

You can bind many events. Bind on Touched in the same way. One after another.
