Get Texture2D from material.

Hi

I am currently trying to create an object where if I click on another object, it gets the object’s material, then gets the texture from that material, and applies that texture to a texture param within it’s own material.

So for example, there is a wooden wall, the player is carrying a ball that looks like concrete, the player clicks the wall, and the ball changes it’s appearance to look like wood.

I have tried a bunch of different ways to make this work, but so far, am unable to do so within blueprints.
Does anybody have an ideas?

I have a habit of solving my own problems moments after asking for help. :stuck_out_tongue:

What I had to do was make sure that the object that I am getting the texture from, has a “Material Instance Dynamic” variable (I called it “MatInst”)
I also needed to make sure there was a TextureSampleParameter2D node inside of the material, which I called “SurfaceTexture”.

Then when I clicked the object, inside of the ball object blueprint, I cast to the object in question (in this case, a “WoodenWall” object), I then got the “MatInst” variable, dragged off a “GetTextureParameterValue” node with the parameter name field set to “SurfaceTexture”.
Inside of the ball blueprint, is another dynamic material instance called “BallMat”, which I also have a TextureSampleParameter2D inside of called “BallTexture”.
I then get the texture out of the GetTextureParameterValue node and set the Texture Parameter for the BallMat to the SurfaceTexture we just exposed.

I am kind of a bit drunk, so this may not make too much sense. I hope it helps someone anyway :slight_smile:

That‘s so humor