// Update is called once per frame void Update() { if (StartCheck) { float newPositionX = transform.position.x - EnemySpeed * Time.deltaTime; float newPositionZ = transform.position.z - EnemySpeed / 3 * Time.deltaTime; transform.position = new Vector3(newPositionX, transform.position.y, newPositionZ); if (newPositionX < -960 || newPositionZ < -540) { EnemySpeed = -EnemySpeed; } else if (newPositionX > 1000 || newPositionZ > 540) { EnemySpeed = -EnemySpeed; } timeCount += Time.deltaTime; if (timeCount > 1) { //GameObject Go = Instantiate (Bullet, transform.position, Quaternion.identity); GameObject Go = BP.NewItem(); Go.transform.localPosition = transform.position; Go.GetComponent <Bullet> ().Init(Target, EnemyIndex); timeCount = 0; } } }