Change Target object Material

image

Hello,

I have a Target object in my project and as a child of that Target I have a plane called ChartImage. What i want to do is hit a button, and change ChartImage’s material. I have already added two materials to ChartImage and I know the button is working because it changes color I press and release it. If anyone has any advice, I would greatly appreciate it.

I found just using states to change it work easier for me. No coding just call the state you want it to be.

Steve

Thanks, that worked perfectly!

out of curiosity, do you know why my code didn’t work?

1 Like

Hi,

First, from a coding point of view, I’m also a bit confused, about what you should/could do with the materials properties… :grin:

But, one way to do it, is by using the skin() function and setting dynamically the material.

Example:

const materialDown = symbol.mediaFiles.your_image_file_down;
const materialUp = symbol.mediaFiles.your_image_file_up;

symbol.nodes.your_button.on("pointerdown", (e) => {
  symbol.nodes.Plane.skin(materialDown);
});

symbol.nodes.your_button.on("pointerup", (e) => {
  symbol.nodes.Plane.skin(materialUp);
});

Cheers,

1 Like

I was going to say the something. I thought you needed to use (skin) to change it.

But to just to change it faster to what I want I’ll use the states.

Steve