Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: gregacuna on November 26, 2019, 04:10:52 AM

Title: Instantiate Material at Runtime
Post by: gregacuna 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.
Title: Re: Instantiate Material at Runtime
Post by: djaydino on November 26, 2019, 04:13:36 AM
Hi.
You can use 'Set Material Property Block Texture' (Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181))
Title: Re: Instantiate Material at Runtime
Post by: gregacuna 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.