void Awake() { gameControllerScript = GameObject.FindObjectOfType <GameControllerScript>(); physs = new PhysicsScript(); gameControllerScript.enemies.Add(this.gameObject); player = gameControllerScript.FindOneRandomPlayer(); }
void FixedUpdate() { time += Time.fixedDeltaTime; if (followPlayer == true) { if (player != null) { if (player.activeSelf == true) { if (time >= inactiveTime) { transform.rotation = physs.LookAt2D(this.gameObject, player); time = 0.0f; } transform.Translate(Vector2.right * followSpeed * followSpeedMultiplier); } else { player = gameControllerScript.FindOneRandomPlayer(); } } } }