Sorting the player's game objects above the other player's game objects

Hi,

For my '2 players' 2D game, both players' game objects are spawned on the same spawn points.
But the remote player's game objects are on top of the local player's game objects.
So to get the local player's game objects on top I put this in the game objects' script:
void Start()
{
if (!photonView.isMine)
{
this.gameObject.transform.position = new Vector3(transform.position.x, transform.position.y, 1);
return;
}
I also tried changing the spriterenderer's sortinglayer and sortingorder but the remote player's game objects stay in front the local player's game objects.
What seems to be the issue?

Best regards
Nikola

Comments

  • Apparently I wasn't very focused.
    The following works:
    this.gameObject.GetComponent ().sortingLayerName = "LayerAbove";