Game Development Reference
In-Depth Information
First, we need to create a new sorting layer. These are special types of layers that
tell Unity the order to render things in. Go to the
Tags & Layers
window and
look out for the drop-down menu called
Sorting Layers
. Add a new layer called
ParticleLayer
on
Layer 1
, as shown in the following screenshot:
With this in place, it means anything with the
Sorting Layers
menu of
ParticleLayer
will render after the
Default
layer. Now, we need a way to assign this
Sorting Layer
to the particle system used when enemies are defeated. Create a new script called
ParticleLayering
and make it look like the following code:
using UnityEngine;
using System.Collections;
public class ParticleLayering : MonoBehaviour
{
public string sortLayerString = "";
void Start ()
{
particleSystem.renderer.sortingLayerName = sortLayerString;
}
}