Example #1
0
    void Shoot()
    {
        GameObject  canonBullet = (GameObject)Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
        CanonBullet bullet      = canonBullet.GetComponent <CanonBullet>();

        if (bullet != null)
        {
            bullet.Seek(target);
        }
    }
Example #2
0
    void Shoot()
    {
        Debug.Log("SHOT");
        // Creates the Bullet game object in the scene
        GameObject bulletGO = (GameObject)Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);

        // A reference to the Bullet script/Component
        // Bullet bullet = bulletGO.GetComponent<Bullet>();
        CanonBullet bullet = bulletGO.GetComponent <CanonBullet>();


        // passes the target/enemt to the bullet class
        if (bullet != null)
        {
            bullet.Seek(target);
        }
    }