using UnityEngine;
using System.Collections;

public class SortPlayer : MonoBehaviour
{
	public Transform OtherPlayer;

	private SpriteRenderer sprite;

	void Start()
	{
		sprite = GetComponent<SpriteRenderer> ();
	}

	void FixedUpdate()
	{
		if (transform.position.y < OtherPlayer.position.y)
		{
			sprite.sortingOrder = 11;	//closer to camera
		}
		else
		{
			sprite.sortingOrder = 10;
		}
	}
}
