playMaker

Author Topic: Instantiate Material at Runtime  (Read 1172 times)

gregacuna

  • Full Member
  • ***
  • Posts: 143
Instantiate Material at Runtime
« on: November 26, 2019, 04:10:52 AM »
Working on a game where the Enemy characters change textures as they are hit. That's working fine, but the problem I've run into is if I'm using prefabs of the same enemies then all of them change texture since they have the same Material.

I'm curious how I can change the material at runtime so that each is unique so changes can be made to an individual enemy without affecting the others.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Instantiate Material at Runtime
« Reply #1 on: November 26, 2019, 04:13:36 AM »
Hi.
You can use 'Set Material Property Block Texture' (Ecosystem)

gregacuna

  • Full Member
  • ***
  • Posts: 143
Re: Instantiate Material at Runtime
« Reply #2 on: November 27, 2019, 08:58:34 AM »
Thanks djaydino...I'll check that. I did find a "Create Material" action in the Ecosystem and I've been able to use that to create a material with a local variable name so that when I make changes to the material it is only for that one.

Hopefully this might help others who run into this same challenge.