Hello,
I decided to create a simple vfx for when the player collides with the exit sign. The problem is that the particle effect is appearing behind the background. I tried adjusting the Z-axis and sorting layer of the effect but I can not get it to move to in front of the background.
I do have the particle system connecting to the exit sign in the prefab and to the one in the scene
Here is what I see:
Here is my code:
public class LevelExit : MonoBehaviour
{
[SerializeField] float waitToLoad = 2f;
[Header("VFX")]
[SerializeField] GameObject levelCompleteVFX;
private void OnTriggerEnter2D(Collider2D other)
{
LevelCompleteVFX();
StartCoroutine(LoadNextLevel());
}
IEnumerator LoadNextLevel()
{
yield return new WaitForSeconds(waitToLoad);
var currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(currentSceneIndex + 1);
}
private void LevelCompleteVFX()
{
if (!levelCompleteVFX) { return; }
GameObject levelVFXObject = Instantiate(levelCompleteVFX, transform.position, transform.rotation);
Destroy(levelVFXObject, 5f);
}
}