// Use this for initialization void Start() { obj = GameObject.Find("Reference"); //oBaseの入っているオブジェクトを探す mother = obj.GetComponent <oBase>(); bulletAngre = transform.localEulerAngles.z; //今の角度を取得 i = mother.firstangle(bulletAngre); //transform.rotation = Quaternion.Euler(0, 0, bulletAngre); }
public void OnTriggerEnter2D(Collider2D other) { bulletAngre = transform.localEulerAngles.z;//今の角度を取得 i = mother.firstangle(bulletAngre); //firstangle(bulletAngre);//判定 if (other.gameObject.tag != "damage") //弾以外に当たった時 { if (count >= maxCount) //既定の回数だけ反射していたら { Destroy(gameObject); //オブジェクトを消す } } if (other.gameObject.tag == "topwall")//上の壁 { count += 1; bulletAngre = mother.Reflection(1, i, bulletAngre); } else if (other.gameObject.tag == "ground")//床 { count += 1; bulletAngre = mother.Reflection(2, i, bulletAngre); } else if (other.gameObject.tag == "leftwall")//左の壁 { count += 1; bulletAngre = mother.Reflection(3, i, bulletAngre); } else if (other.gameObject.tag == "rightwall") { count += 1; bulletAngre = mother.Reflection(4, i, bulletAngre); } else if (other.gameObject.tag == "damage2") { Destroy(gameObject); } transform.rotation = Quaternion.Euler(0, 0, bulletAngre); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "weapon") { combo.Combo(); //x = collision.transform.position.x - transform.position.x; //y = collision.transform.position.y - transform.position.y; x = transform.position.x - collision.transform.position.x; y = transform.position.y - collision.transform.position.y; angle = Mathf.Atan2(y, x) * Mathf.Rad2Deg; reflect = _oBase.firstangle(angle); try { Destroy(particle); } catch (System.Exception e) { } if (collision.transform.position.x > transform.position.x) { angle -= 180; } if (_tWeakPointParent.FlgWeakness || hpGage.Remaining <= 0.0f || (enemyName != "boss" && parent.gameObject.name != "Enemy9")) { //吹っ飛び倍率 magnification = hitAcseel; //パーティクル生成 particle = Instantiate(blowParticle2, parent.transform.position, Quaternion.identity); particle.name = "BlowParticle"; particle.transform.parent = this.parent.transform; particle.transform.rotation = Quaternion.Euler(0, 0, angle); } else { //吹っ飛び倍率 magnification = Weakness; //パーティクル生成 particle = Instantiate(hitParticle, parent.transform.position, Quaternion.identity); particle.name = "HitParticle"; Destroy(particle, 0.2f); } x *= magnification; flg = true; flgBlow = true; box2D.enabled = false;//跳ね返ってPlayerに当たらないように } //壁や床に当たったとき反射する if (flgBlow) { Reflect(collision.gameObject.tag); } }