// Use this for initialization void Start() { //スクリプトを読み込む hpapi = GameObject.Find("Canvas").GetComponent <HpApi>(); boss = GameObject.Find("Boss_C").GetComponent <Boss_C>(); //現在アタッチされているオブジェクトを読み込む wepon = transform.root.gameObject; //向きの修正 if (boss.transform.position.x - boss.playerPosithion.x < 0) { transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z); } //向きに応じて速度を与える if (boss.transform.localScale.x < 0) { wepon.GetComponent <Rigidbody>().velocity = new Vector3(weponSpeed, wepon.transform.position.y, wepon.transform.position.z); } else { wepon.GetComponent <Rigidbody>().velocity = new Vector3(-weponSpeed, wepon.transform.position.y, wepon.transform.position.z); } }
// Use this for initialization void Start() { //スクリプトを読み込む hpapi = GameObject.Find("Canvas").GetComponent <HpApi>(); boss = GameObject.Find("Boss_C").GetComponent <Boss_C>(); //向きの修正 if (boss.transform.position.x - boss.playerPosithion.x < 0) { transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z); } else { } }
// Use this for initialization void Start() { //スクリプトを読み込む hpapi = GameObject.Find("Canvas").GetComponent <HpApi>(); boss = GameObject.Find("Boss_C").GetComponent <Boss_C>(); }