private void Awake() { _rigidbody2D = GetComponent <Rigidbody2D>(); _enemy = GetComponent <Enemy>(); _screenBoundaries = GetComponent <ScreenBoundaries>(); Assert.IsNotNull(_rigidbody2D); Assert.IsNotNull(_enemy); Assert.IsNotNull(_screenBoundaries); }
void Awake() { box2D = GetComponent <BoxCollider2D>(); bottomCorner = ScreenBoundaries.CalcBottomCorner(transform.position); topCorner = ScreenBoundaries.CalcTopCorner(transform.position); float addition = box2D.size.x * transform.localScale.x / 2; minX = bottomCorner.x + addition; maxX = topCorner.x - addition; }
// Start is called before the first frame update void Start() { boundaries = GetComponent <ScreenBoundaries>(); mesh = GetComponent <MeshRenderer>(); if (target == null) { if (GameObject.FindWithTag("Player") != null) { target = GameObject.FindWithTag("Player").GetComponent <Transform>(); } } StartCoroutine("FlyerActions"); }
private static ScreenBoundaries CreateScreenBoundaries() { GameObject SB = new GameObject(); SB.name = "ScreenBoundaries"; SB.transform.position = Vector3.zero; SB.transform.localScale = Vector3.one; BoxCollider2D boxCollider2D = SB.AddComponent <BoxCollider2D>(); boxCollider2D.isTrigger = true; ScreenBoundaries screenBoundaries = SB.AddComponent <ScreenBoundaries>(); return(screenBoundaries); }
// Start is called before the first frame update void Start() { boundaries = GetComponent <ScreenBoundaries>(); SpawnEnemies(); }