示例#1
0
 void Start()
 {
     anim         = GetComponent <Animator>();
     rigidbody2D  = GetComponent <Rigidbody2D>();
     kizunaScript = GameObject.FindWithTag("KP").GetComponent <Kizuna> ();
     //無敵
     renderer    = GetComponent <Renderer> ();
     audioSource = GetComponent <AudioSource> ();
 }
示例#2
0
    void Start()
    {
        //ユニティちゃんオブジェクトを取得
        player       = GameObject.FindWithTag("UnityChan");
        kizunaScript = GameObject.FindWithTag("KP").GetComponent <Kizuna> ();
        //rigidbody2Dコンポーネントを取得
        Rigidbody2D rigidbody2D = GetComponent <Rigidbody2D>();

        //ユニティちゃんの向いている向きに弾を飛ばす
        rigidbody2D.velocity = new Vector2(speed * player.transform.localScale.x, rigidbody2D.velocity.y);
        //画面の向きをユニティちゃんに合わせる
        Vector2 temp = transform.localScale;

        temp.x = player.transform.localScale.x;
        transform.localScale = temp;
        //5 秒後に消滅
        Destroy(gameObject, 5);
    }