There's more...

If you have multiple enemies and want each one to have its own weight, you have to create a different material for each one of them. This is necessary as materials are normally shared between models and changing one will change all of them. There are several ways in which you can do this; the quickest one is to create a script that automatically does it for you. The following script, once attached to an object with a Renderer, will duplicate its first material and set the _Amount property automatically:

using UnityEngine;public class NormalExtruder : MonoBehaviour {  [Range(-0.0001f, 0.0001f)]  public float amount = 0;  // Use this for initialization  void Start ()   { Material material = GetComponent<Renderer>().sharedMaterial; ...

Get Unity 2018 Shaders and Effects Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.