Example #1
0
    private void Update()
    {
        pos = transform.position;

        if (pos.y > 0 && isReturn == false)
        {
            // Translate(x軸, y軸, z軸)
            // x軸がプラス →方向のベクトル
            // z軸がマイナス ↓方向のベクトル
            // この2つのベクトルを合成すると「↘️」方向のベクトルになる。(→ + ↓ = ↘️)
            transform.Translate(moveDistance * Time.deltaTime, 0, -moveDistance * Time.deltaTime, Space.World);
        }
        else // pos.zが1以下になった時、進行方向を変化させる。
        {
            isReturn = true;

            // x軸がプラス →方向のベクトル
            // z軸がマイナス ↑方向のベクトル
            // この2つのベクトルを合成すると「↗️」方向のベクトルになる。(→ + ↑ = ↗️)
            transform.Translate(moveDistance * Time.deltaTime, 0, moveDistance * Time.deltaTime, Space.World);
        }
        if (CUtility.IsOut(transform.position))
        {
            Destroy(gameObject);
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        float ShotSpeed = 3.0f;
        int   wayNum    = 5;
        float angle     = 40.0f;

        Count++;

        player = GameObject.FindGameObjectWithTag("Player");
        if (player != null)
        {
            if (Count % 70 == 0)
            {
                for (int i = 0; i < wayNum; i++)
                {
                    Vector2 vec = player.transform.position - transform.position;
                    vec.Normalize();
                    float anglePerShot = angle / (wayNum - 1);
                    vec  = Quaternion.Euler(0, 0, anglePerShot * i - angle / 2.0f) * vec;
                    vec *= ShotSpeed;
                    var q = Quaternion.Euler(0, 0, -Mathf.Atan2(vec.x, vec.y) * Mathf.Rad2Deg);
                    var t = Instantiate(EneShot02, transform.position, q);
                    t.GetComponent <Rigidbody2D>().velocity = vec;
                }
            }
        }
        else
        {
            angle = Mathf.PI + (Mathf.PI / 2);
        }
        if (CUtility.IsOut(transform.position))
        {
            Destroy(gameObject);
        }
    }
Example #3
0
 // Update is called once per frame
 void Update()
 {
     if (CUtility.IsOut(transform.position))
     {
         Destroy(gameObject);
     }
 }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        x = radius * Mathf.Sin(Time.time * speed);                              //X軸の設定
        y = radius * Mathf.Tan(Time.time * speed);                              //Y軸の設定

        transform.position = new Vector3(x + defPosition.x, y + defPosition.y); //自分のいる位置から座標を動かす。

        if (CUtility.IsOut(transform.position))
        {
            Destroy(gameObject);
        }
    }
Example #5
0
    // Update is called once per frame
    void Update()
    {
        Count++;
        if (Count > 0)
        {
            transform.position += new Vector3(3.0f, 0.0f, 0.0f) * Time.deltaTime;
        }

        if (CUtility.IsOut(transform.position))
        {
            Destroy(gameObject);
        }

        transform.position = new Vector2(transform.position.x
                                         , 2.5f + Mathf.Sin(Time.frameCount * wave));
    }
Example #6
0
    // Update is called once per frame
    void Update()
    {
        Count++;

        if (Count < 30)
        {
            transform.position += new Vector3(0.0f, -3.0f, 0.0f) * Time.deltaTime;
        }
        if (Count > 300)
        {
            transform.position += new Vector3(0.0f, 3.0f, 0.0f) * Time.deltaTime;
        }
        if (CUtility.IsOut(transform.position))
        {
            Destroy(gameObject);
        }
    }
Example #7
0
    // Update is called once per frame
    void Update()
    {
        Vector3 pos = GameObject.FindGameObjectWithTag("Player").transform.position;
        Vector3 dir = pos - transform.position;

        Angle = Mathf.Atan2(pos.y - transform.position.y, pos.x - transform.position.x);
        print(Angle);
        transform.position += CUtility.GetDirectionPI2(Angle) * Speed * Time.deltaTime;

        // 弾が進行方向を向くようにする
        var angles = transform.localEulerAngles;

        angles.z = Angle * Mathf.Rad2Deg - 90;
        transform.localEulerAngles = angles;

        if (CUtility.IsOut(transform.position))
        {
            Destroy(gameObject);
        }
    }
Example #8
0
 // Update is called once per frame
 void Update()
 {
     if (Cnt < 80)
     {
         transform.position += new Vector3(0.0f, -3.0f, 0.0f) * Time.deltaTime;
     }
     if (Cnt == 300)
     {
         GameObject.Find("GameManager").GetComponent <CGameManager>().BulletFactory[0].CreateBullet(transform.position, 0);
     }
     if (Cnt > 80 + 240)
     {
         transform.position += new Vector3(0.0f, 3.0f, 0.0f) * Time.deltaTime;
     }
     Cnt++;
     if (CUtility.IsOut(transform.position))
     {
         Destroy(gameObject);
     }
 }
Example #9
0
 //GameObject newParent = new GameObject();
 // Update is called once per frame
 void Update()
 {
     if (Cnt < 100)
     {
         transform.position += new Vector3(0.0f, -3.0f, 0.0f) * Time.deltaTime;
     }
     if (Cnt == 300)
     {
         CSoundPlayer.PlaySound("enemy_shot", true);
         GameObject.Find("GameManager").GetComponent <CGameManager>().BulletFactory[3].CreateBullet(transform.position, 0);
     }
     if (Cnt > 340)
     {
         transform.position += new Vector3(0.0f, 3.0f, 0.0f) * Time.deltaTime;
     }
     Cnt++;
     if (CUtility.IsOut(transform.position))
     {
         Destroy(gameObject);
     }
 }
Example #10
0
    // Update is called once per frame
    void Update()
    {
        float ShotSpeed = 8.0f;

        if (count % 6 == 0)
        {
            for (int i = 0; i < 12; i++)
            {
                Vector2 vec = new Vector2(0.0f, 1.0f);
                vec = Quaternion.Euler(0, 0, 0.2f * count) * vec;
                vec.Normalize();
                vec  = Quaternion.Euler(0, 0, (360 / 12) * i) * vec;
                vec *= ShotSpeed;
                var q = Quaternion.Euler(0, 0, -Mathf.Atan2(vec.x, vec.y) * Mathf.Rad2Deg);
                var t = Instantiate(EneShot01, transform.position, q);
                t.GetComponent <Rigidbody2D>().velocity = vec;
            }
        }
        count++;
        if (CUtility.IsOut(transform.position))
        {
            Destroy(EneShot01);
        }
    }