Dynamic Material Instancing through another blueprint?

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

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

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.

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.

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?

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:

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:

ColorSeats seem to be it here.

I have a soft spot for hexes :wink:

Good luck with the rest!

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

  • in the Hex Actor:

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

  • in the spawner:

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.

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

You have two options:

Image from Gyazo

342185-screenshot-2.png

Or:

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

Is identical to the one on the Event Dispatcher:

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

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?

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

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

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

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

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

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

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:

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.

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.

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!

Wait its working

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?

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