playMaker

Author Topic: Change a slider value on a Shader Forge shader material?[SOLVED]  (Read 6661 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
Hello. I want to change the "Health Amount" slider of my material via a Playmaker action. The Health Amount slider on my Shader Forge Shader material will change the opacity, color, and length of a health bar material.

How do we "get" and set the different editable values of that material at runtime?

This would also be useful for burning up an object that has a fire erosion effect, or it would be useful for changing the material to slowly become wet when the game starts raining.

What is the best way to get and set these properties?

In some cases I want to affect the material and cause it to affect all objects with that shader in the scene. In other cases, I am also hoping that changing properties of this material on one object won't change the way it looks on other objects, since different enemies will use the same material but have different health amounts.
« Last Edit: November 18, 2016, 02:58:41 AM by jeanfabre »

Ubik3D

  • Playmaker Newbie
  • *
  • Posts: 22
    • www.hypnorama.se
Re: Change a slider value on a Shader Forge shader material?
« Reply #1 on: July 02, 2016, 05:03:57 AM »
Use the 'Set Material Float' action.

I tried with the Shader Forge example scene and got it to work.

You have to name the exposed parameter by name, and it works if you type it as it says in the code, not as it is displayed in the material. E.g. use float name "_BulgeScale" instead of "Bulge Scale".

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
Re: Change a slider value on a Shader Forge shader material?
« Reply #2 on: July 14, 2016, 09:24:35 AM »
that's great. thanks. is it possible to lerp a material float over time, to smoothly go from full black to full clear opacity over 2 seconds?

Ubik3D

  • Playmaker Newbie
  • *
  • Posts: 22
    • www.hypnorama.se
Re: Change a slider value on a Shader Forge shader material?
« Reply #3 on: November 04, 2016, 08:57:15 PM »
Absolutely. Use "Animate Color" or "Ease Color" actions and then "Set Material Color".