private void CheckIfOffscreen() { if (this.transform.position.y > edge.GetTop().y) { this.gameObject.SetActive(false); } if (this.transform.position.y < edge.GetBotton().y) { this.gameObject.SetActive(false); } if (this.transform.position.x < edge.GetLeft().x) { this.gameObject.SetActive(false); } if (this.transform.position.x > edge.GetRight().x) { this.gameObject.SetActive(false); } }
void SpawnEnemy(ObjectPooler pool) { ScreenEdgeReference reference = ScreenEdgeReference.Instance; float randomX = 0; if (Random.Range(0, 2) == 0) { randomX = reference.GetLeft().x; } else { randomX = reference.GetRight().x; } float randomY = Random.Range(reference.GetBotton().y, reference.GetTop().y); GameObject enemy = PoolManager.Instance.GrabFromPool(pool); enemy.SetActive(true); enemy.transform.SetPositionAndRotation(new Vector3(randomX, randomY, 0), Quaternion.identity); }
private void WarpToLeft() { Vector3 vec = new Vector3(edge.GetLeft().x, t.position.y, t.position.z); t.SetPositionAndRotation(vec, t.rotation); }