// Update is called once per frame void Update() { //Debug.Log (this.gameObject.transform.position); if (cur == movestage.second) { this.GetComponent <Rigidbody> ().velocity = new Vector3(-2 * speed, 0f, 0f); if (this.gameObject.transform.position.x - this.gameObject.transform.lossyScale.x / 2 >= camW / 2) { Destroy(this.gameObject); return; } else if (this.gameObject.transform.position.x - this.gameObject.transform.lossyScale.x / 2 <= -camW / 2) { Destroy(this.gameObject); return; } } else { float tmp = this.gameObject.transform.position.x - shiprigidbody.gameObject.transform.position.x; if (tmp >= camW / 3) { if (tmp >= camW / 2) { this.GetComponent <Rigidbody> ().velocity = new Vector3(2 * speed, 0f, 0f); } else { this.GetComponent <Rigidbody> ().velocity = new Vector3(0f, 0f, 0f); //currReload -= Time.deltaTime; //if (currReload > 0){ // return; //} //else{ StartCoroutine(delay()); Instantiate(EWeapon, this.gameObject.transform.position, this.gameObject.transform.rotation); cur = movestage.second; this.GetComponent <Rigidbody> ().velocity = new Vector3(-2 * speed, 0f, 0f); //currReload = reload; //} } } //else if (tmp>0) { // this.GetComponent<Rigidbody> ().velocity = new Vector3 (-speed, 0f, 0f); //currReload = reload; //} else { this.GetComponent <Rigidbody> ().velocity = new Vector3(speed, 0f, 0f); //currReload = reload; } } }
// Update is called once per frame void Update() { //Debug.Log (this.gameObject.transform.position); if (cur == movestage.second) { this.GetComponent<Rigidbody> ().velocity = new Vector3 (-2*speed, 0f, 0f); if (this.gameObject.transform.position.x - this.gameObject.transform.lossyScale.x / 2 >= camW / 2) { Destroy(this.gameObject); return; } else if (this.gameObject.transform.position.x - this.gameObject.transform.lossyScale.x / 2 <= -camW / 2){ Destroy(this.gameObject); return; } } else { float tmp = this.gameObject.transform.position.x-shiprigidbody.gameObject.transform.position.x; if (tmp>=camW/3 ) { if (tmp >= camW/2){ this.GetComponent<Rigidbody> ().velocity = new Vector3 (2*speed, 0f, 0f); } else{ this.GetComponent<Rigidbody> ().velocity = new Vector3 (0f, 0f, 0f); //currReload -= Time.deltaTime; //if (currReload > 0){ // return; //} //else{ StartCoroutine (delay()); Instantiate (EWeapon, this.gameObject.transform.position, this.gameObject.transform.rotation); cur = movestage.second; this.GetComponent<Rigidbody> ().velocity = new Vector3 (-2*speed, 0f, 0f); //currReload = reload; //} } } //else if (tmp>0) { // this.GetComponent<Rigidbody> ().velocity = new Vector3 (-speed, 0f, 0f); //currReload = reload; //} else{ this.GetComponent<Rigidbody> ().velocity = new Vector3 (speed, 0f, 0f); //currReload = reload; } } }