using System.Collections; using System.Collections.Generic; using UnityEngine; public class BulletController : MonoBehaviour { // Start is called before the first frame update //public GameObject BulletPrefab; public float Bullet_speed = 5.0f; float span = 1.0f; float delta = 0; public GameObject BulletPrefab; void Start() { } // Update is called once per frame void Update() { this.delta += Time.deltaTime; if (this.delta > this.span) { this.delta = 0; } if (this.gameObject.transform.localScale.x == 1) { // 往右移動 this.gameObject.transform.Translate(Bullet_speed *Time.deltaTime*1, 0, 0); } if (this.gameObject.transform.localScale.x == -1) { // 往左移動 this.gameObject.transform.Translate(Bullet_speed *Time.deltaTime*-1, 0, 0); } if ((transform.position.x >= 8) | (transform.position.x <= -8)) { Destroy(gameObject); } } }