#I have this scene in progress where I m
1 messages · Page 1 of 1 (latest)
I figured out how to change the sort order when entering a collider. But now I'm also trying to have the sprite ignore the colliders on the stairs via changing the layers to ignore the staircase
{
sprite = GetComponent<SpriteRenderer>();
}
void FixedUpdate()
{
if (insideTrigger == true)
{
gameObject.layer = LayerMask.NameToLayer("IgnoreElevationColliders");
sprite.sortingOrder = 0;
} else
{
gameObject.layer = default;
sprite.sortingOrder = sortingOrder;
};
}
void OnTriggerEnter2D(Collider2D col)
{
Debug.Log("Character is entered trigger zone of " + col.name);
insideTrigger = true;
}
private void OnTriggerExit2D(Collider2D col)
{
Debug.Log("Character exited trigger zone of " + col.name);
insideTrigger = false;
}
}```
When i run this, the Layer changes and ignores the colliders properly but then the sorting order doesn't work...
it basically keeps switching between the if & else nonstop