using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Layer_Down_Trigger : MonoBehaviour {
// Use this for initialization
void Start () {
GetComponent<Renderer>().sortingLayerName = "PlayerOverlay";
GetComponent<Renderer>().sortingLayerName = "WorldObjects";
}
// Update is called once per frame
void Update ()
{
}
void OnTriggerEnter2D(Collider2D other) {
if(other.gameObject.tag =="Player")
{
Renderer.sortingLayerName = "PlayerOverlay";
}
else
{
Renderer.sortingLayerName = "WorldObjects";
}
}
}
hello, i’ve got a box collider2D on my player with a trigger and what im trying to achieve when the trigger on my player goes into another box collider2D trigger it change the sorting layer of the area the player is inside. ive looked for a while to find whats the correct code to change sorting layer but its just mixed anwsers. ill post my current script.
Edit: Renderer.sortingLayerName = “sortinglayername”; could be the code but its saying it needs an object reference now, the brackets are in the right place its just formated to the left when i posted