void OnCollisionStay2D(Collision2D col) { if (!col.gameObject.CompareTag("Player")) { return; } Debug.Log("staying"); Vector2 myPos = collider2D.bounds.ClosestPoint((Vector2)transform.position + direction * 100); Vector2 oPos = col.collider.bounds.ClosestPoint((Vector2)col.gameObject.transform.position + -direction * 100); PlayerDeath player = col.collider.gameObject.GetComponent <PlayerDeath>(); Debug.Log("my" + myPos); Debug.Log("player" + oPos); switch ((int)directionToMove) { case 0: { if (Mathf.Abs(myPos.y - oPos.y) > killthreshold) { player.Kill(); } } break; case 1: { if (Mathf.Abs(oPos.y - myPos.y) > killthreshold) { player.Kill(); } } break; case 2: { if (Mathf.Abs(myPos.x - oPos.x) > killthreshold) { player.Kill(); } } break; case 3: { if (Mathf.Abs(oPos.x - myPos.x) > killthreshold) { player.Kill(); } } break; } }