playMaker

Author Topic: Material Instance [SOLVED]  (Read 86 times)

MajorIdea

  • Full Member
  • ***
  • Posts: 111
    • View Profile
Material Instance [SOLVED]
« on: October 30, 2017, 01:52:27 PM »
Hey,

Isn't there an action like a Set Material Renderer Color or Float?

I'm trying to fade objects like trees between the camera and the player and if I do a Set Material Float and change the opacity it changes all the trees instead of the ones detected.

I noticed for example the Dotween action "Color Renderer To" creates an instance of the material but I cant seem to find another way to do that. Is there?
« Last Edit: November 03, 2017, 03:01:40 PM by MajorIdea »

Deek

  • Junior Playmaker
  • **
  • Posts: 63
    • View Profile
Re: Material Instance
« Reply #1 on: October 31, 2017, 04:30:45 AM »
You have to use 'Set Material Color' and leave the "Material" empty or set it to none for it to only affect the current material instance, because if you set the "Material", the action will directly change the values of the material in your Assets folder, thus applying those changes to every GameObject that uses this material.

I'd agree that there should be a more clear differentiation or explanation of this behaviour, since it isn't really obvious in that action and took me some time to figure out back then when I needed it to only affect instances.

Now you can use 'Ease Color' from white with full alpha (or whatever color your material has) to white with zero alpha, use that eased color in your 'Set Material Color' and set that to run every frame to fade out the current tree.


I assume you could also use Set Property on the required GameObjects and ease the Color>a (Alpha) to see if it changes the color of all trees or only the current one, but the first method should suffice.

MajorIdea

  • Full Member
  • ***
  • Posts: 111
    • View Profile
Re: Material Instance
« Reply #2 on: November 03, 2017, 03:01:15 PM »
That totally works.

Although if doesn't work if I set the material to none, has to be empty.

Thanks!