Re: Set the character Z-index when they are in Idle
I threw this together, it should work.
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
//Attach to your character prefab
private ControlsScript myControlsScript;
[SerializeField]
private int spriteRendererSortingOrder;
private void Start()
{
myControlsScript = GetComponentInParent<ControlsScript>();
}
private void Update()
{
UpdateSpriteRenderer();
}
private void UpdateSpriteRenderer()
{
if (myControlsScript == null
|| myControlsScript.mySpriteRenderer == null)
{
return;
}
if (myControlsScript.currentBasicMove == BasicMoveReference.Idle)
{
myControlsScript.mySpriteRenderer.sortingOrder = spriteRendererSortingOrder;
}
}
}
Re: Set the character Z-index when they are in Idle
Thank you but where would I set the z-index to 0?
Re: Set the character Z-index when they are in Idle
By Z-Index do you mean sorting order?
The script has a variable you set in the inspector.