playMaker

Author Topic: Can't access projector material properties [SOLVED]  (Read 561 times)

RobotGoggles

  • Playmaker Newbie
  • *
  • Posts: 35
Can't access projector material properties [SOLVED]
« on: October 15, 2022, 04:36:06 PM »
I created a custom projector shader in Amplify to handle blood splats that make a nice evaporating when you change the color alpha, and changing it manually at runtime works great - I can't seem to access this material's values through Playmaker though.

I can't use the "Set Material Color" action since it requires a renderer component, which the projector component doesn't use.

I've used "Get Component" and "Get Property" to get the Projector.material.color.a property and set that, but this makes all instances of the splats fade out at the same time (not the desired effect  :-\ ) even though I've enabled instancing on the material. I'm not sure if there's some other step needed for that approach.

I also can't just animate the values, which would be the easiest. Unity's animation editor can't seem to access material values either, without a renderer component

I'm pretty stumped. Any help would be helpful.

« Last Edit: November 04, 2022, 08:02:15 PM by RobotGoggles »
When life hands you insomnia, make video games.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Can't access projector material properties
« Reply #1 on: October 17, 2022, 06:40:51 AM »
Hi.
maybe try to search unity forums if there is a way.
if so, link here.

RobotGoggles

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Can't access projector material properties
« Reply #2 on: November 04, 2022, 07:58:37 PM »
For anyone with a similar problem - I've figured it out, ort at least found a solution that works for me. I've since switched to URP and their DecalProjector, which work essentially the same aside from the blend modes but that didn't really fix the issue, however I did find an FSM solution.

Just after spawning the prefab with the projector on it, I used Get Component to grab the projector object, then created a new material with my custom shader on it and assigned it to the projector's material property. Then I needed to use Get Property to get the material I just assigned. This sounds redundant, but when you set the material property you're only pointing to the material value, but when you get the same component property you get the instance of the material that you just created.

It should also be noted that when you later use the set material texture/color/etc. the material index should be set to 'none'.

When life hands you insomnia, make video games.