Pages 1
Universal Fighting Engine Forum We are no longer using the forum to answer questions due to bot attacks. Please use our discord instead: https://discord.gg/hGMZhF7 |
You are not logged in. Please login or register.
Universal Fighting Engine Forum → Source Coding → 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;
}
}
}
Thank you but where would I set the z-index to 0?
By Z-Index do you mean sorting order?
The script has a variable you set in the inspector.
Universal Fighting Engine Forum → Source Coding → Set the character Z-index when they are in Idle
Powered by PunBB, supported by Informer Technologies, Inc.