Trail Render is rendering behind the background sprite

I tried various posts on this site, nothing seems to work. I’m really frustrated.

I created a new project, then added a PNG that follows the mouse, like pointer. (Sorting order = 1 / Z position = 1)

and another sprite that stays at the background. (Sorting order = 0 / Z position = 0)

wrote a script and attached it with the pointer,

this is the script,

	public TrailRenderer trail;
	// Use this for initialization
	void Start(){

		//trail.sortingLayerName = "Background";
		trail.sortingOrder = 1;
	}
	
	// Update is called once per frame
	void Update () {
		Vector3 temp = Camera.main.ScreenToWorldPoint(Input.mousePosition);
		temp.z = 1f;
		transform.position = temp;
	}
}

and added a Trail Render component to the pointer and dragged and dropped it to the “Trail” that i assigned in the code so that i can apply the Sorting layer 1 to it. (that i just defined in the code).

now the pointer’s sorting layer is 1, trail render’s sorting layer is 1. and BG image’s sorting layer is 0.

i hit play and take a look at my student loan papers and wonder how i’m going to repay because the pointer is on top of the background and follows the mouse (just like i wanted) but the trail render is working behind the background (like the heck?)

i trited putting both the background and pointer in side a gameobject and added sprite renderer to them and did the sorting layer thing again, tried one with gameobject and other without it and stuff. nothing worked.

i tried, and need help :cry:

Sorting order is not Z position, please check your scene in 3D mode and see the difference.

Set your background to a lower sorting order (like -5) and trail renderer sorting order to higher (like 5) and keep their Z transform at zero.

When you inspect your scene in 3D mode (preferable in pause mode, since everything is rendered) you can actually see their position to the camera.