/* * void Update() * { * if (shootCooldown > 0) * { * shootCooldown -= Time.deltaTime; * } * else * { * Attack(); * } * } */ public void Attack() { //shootCooldown = shootingRate; var shotTransform = Instantiate(shotPrefab) as Transform; shotTransform.position = transform.position; BossProjectileMoveScript move = shotTransform.gameObject.GetComponent <BossProjectileMoveScript>(); shotTransform.position += new Vector3(-7, 2.5f, 0); var tempVector = shotTransform.position; tempVector.z = -2; shotTransform.position = tempVector; if (targetSwitch) { targetVector = target1.position - transform.position; move.direction = targetVector; targetSwitch = false; } else { targetVector = target2.position - transform.position; move.direction = targetVector; targetSwitch = true; } }
//private float shootCooldown; /* * void Start() * { * shootCooldown = 4.5f; * } * * void Update() * { * if (shootCooldown > 0) * { * shootCooldown -= Time.deltaTime; * } else * { * Attack(); * } * } */ public void Attack() { //shootCooldown = shootingRate; var shotTransform = Instantiate(shotPrefab) as Transform; shotTransform.position = transform.position; BossProjectileMoveScript move = shotTransform.gameObject.GetComponent <BossProjectileMoveScript>(); shotTransform.position += new Vector3(-7, -4.5f, 0); var tempVector = shotTransform.position; tempVector.z = -2; shotTransform.position = tempVector; move.direction = this.direction; }