Exemplo n.º 1
0
        void Shoot()
        {
            Bullet bullet = GetBulletObject().GetComponent <Bullet> ();

            bullet.gameObject.transform.position = transform.position;
            bullet.AddForce((m_PlayerTransform.position - transform.position).normalized * 20.0f);
        }
Exemplo n.º 2
0
    private Bullet LaunchBullet(Vector3 spawnPos)
    {
        // instantiate the Bullet
        Bullet     b   = Instantiate(bullet, spawnPos, Quaternion.identity);// as GameObject;
        Quaternion rot = Quaternion.Euler(new Vector3(0, 180, 0));

        b.heading = rot;// Bullet bp = b.GetComponent<Bullet>();
        b.AddForce(new Vector3(0, 240.0f, 0));
        return(b);
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        Rigidbody Bullet;

        BulletPosition.Set(transform.position.x, transform.position.y + 1, transform.position.z + 10);
        BulletRotation.Set(0, 180, 0, 0);


        //Debug.Log(transform.position);
        //Debug.Log(BulletPosition);

        Bullet = Instantiate(bullet_template, BulletPosition, BulletRotation) as Rigidbody;
        Bullet.AddForce(0, 0, 3000);
    }
Exemplo n.º 4
0
    void Update()
    {
        if (rb.position.y < -10)
        {
            FindObjectOfType <GameManager>().EndGame();
        }

        // to make it constant with the frame rate
        if (Input.GetKey("w"))
        {
            // rb.AddForce(0, 0, sf , ForceMode.VelocityChange);
            //check
            rb.AddForce(0, 0, sf);
            //anim.SetBool("test", true);
        }

        //anim.SetBool("test", false);
        if (Input.GetKey("d"))
        {
            //rb.AddForce(sf, 0,0, ForceMode.VelocityChange);
            rb.AddForce(sf, 0, 0);
            //if (onetime == true)
            //{
            // test9.Set(0, 0, 5);
            // test9.Set(0, 0, 10);
            //test9.Set(0, 0, 15);
            //test9.Set(0, 0, 20);
            //onetime = false;
            //transform.Rotate(test9);

            // }
        }
        if (Input.GetKey("s"))
        {
            //rb.AddForce(0, 0, -sf , ForceMode.VelocityChange);
            rb.AddForce(0, 0, -sf);
            onetime = true;
        }
        if (Input.GetKey("a"))
        {
            //rb.AddForce(-sf, 0, 0, ForceMode.VelocityChange);
            rb.AddForce(-sf, 0, 0);
        }

        if (Input.GetKey("e"))
        {
            ParticleSystem Fire_update;
            FireRotation.Set(90, 0, 0, 0);
            rb.AddForce(0, sf, 0);
            //FirePosition.Set(transform.position.x, transform.position.y - 2, transform.position.z);
            //Fire.transform.position = FirePosition;
            //Fire_update = Instantiate(Fire, FirePosition, FireRotation);
        }

        if (Input.GetKey("q"))
        {
            Rigidbody Bullet;
            BulletPosition.Set(transform.position.x, transform.position.y - 1, transform.position.z + 10);
            BulletRotation.Set(0, 180, 0, 0);


            //Debug.Log(transform.position);
            //Debug.Log(BulletPosition);

            Bullet = Instantiate(bullet_template, BulletPosition, BulletRotation) as Rigidbody;
            Bullet.AddForce(0, 0, 3000);
        }



        // we then will add the friciton
    }