void LateUpdate() { Vector3 ViewPosition = transform.position; ViewPosition.x = Mathf.Clamp(ViewPosition.x, ScreenBounds.x * -1, ScreenBounds.x); ViewPosition.y = Mathf.Clamp(ViewPosition.y, ScreenBounds.y * -1, ScreenBounds.y); float X = transform.transform.position.x; float Y = transform.transform.position.y; if (X <= -screenWidth || X >= screenWidth || Y <= -screenHeight || Y >= screenHeight) { uiapi.DecEgg(); Destroy(gameObject); } }