public void OnTriggerExit2D(Collider2D C2D) { if (C2D.GetComponent <CharacterLimit>()) { CharacterLimit CL = C2D.GetComponent <CharacterLimit>(); if (LeftLimits.Contains(CL)) { LeftLimits.Remove(CL); } else if (RightLimits.Contains(CL)) { RightLimits.Remove(CL); } } }
public void OnTriggerEnter2D(Collider2D C2D) { if (C2D.GetComponent <CharacterLimit>()) { CharacterLimit CL = C2D.GetComponent <CharacterLimit>(); if (CL.LimitDirection == Direction.Left && !LeftLimits.Contains(CL)) { LeftLimits.Add(CL); } else if (CL.LimitDirection == Direction.Right && !RightLimits.Contains(CL)) { RightLimits.Add(CL); } } }