Example #1
0
    void Update()
    {
        if (Input.GetAxis("Fire1") > 0 && Time.time >= nextFire)
        {
            nextFire = Time.time + fireRate;
            GameObject Temp_Bullet_Handler;

            Temp_Bullet_Handler = Instantiate(bullet, emitter.transform.position, emitter.transform.rotation) as  GameObject;
            //Temp_Bullet_Handler.transform.Rotate(Vector3.left*90);

            Rigidbody TempRB;
            TempRB = Temp_Bullet_Handler.GetComponent <Rigidbody>();

            TempRB.velocity = transform.TransformDirection(new Vector3(0, 0, speed));

            Destroy(Temp_Bullet_Handler, 10.0f);
        }
        ;
    }
Example #2
0
    void Update()
    {
        transform.LookAt(player.transform.position);

        if (Time.time >= nextFire && Time.time >= 10)
        {
            nextFire = Time.time + fireRate;
            GameObject Temp_Bullet_Handler;
            Temp_Bullet_Handler = Instantiate(bullet, emitter.transform.position, emitter.transform.rotation) as  GameObject;

            Rigidbody TempRB;

            TempRB = Temp_Bullet_Handler.GetComponent <Rigidbody>();

            TempRB.velocity = transform.TransformDirection(new Vector3(Random.Range(-tangSpeed, tangSpeed), Random.Range(-tangSpeed, tangSpeed), speed));

            Destroy(Temp_Bullet_Handler, 10.0f);
        }
        ;
    }