private void ShootBullet(Vector3 direction)
    {
        // Get bullet from the pool
        GameObject bullet = BulletPool.GetFromPool();

        // Reset its position according to the barrel position
        bullet.transform.SetPositionAndRotation(BarrelPosition.position, Quaternion.identity);
        // This to help debug the wired bug in bullet movement
        Debug.DrawRay(bullet.transform.position, direction, Color.cyan, 0.1f);
        // Fire Bullet
        bullet.GetComponentInChildren <BulletController>().Fire(direction);
    }
Beispiel #2
0
    public void Shoot()
    {
        m_particleSys.Play();
        GameObject currentBullet = _bulletsPool.GetFromPool();

        currentBullet.GetComponent <Bullet>().target = owner == characterType.PLAYER ? characterType.ENEMY : characterType.PLAYER;
        currentBullet.transform.position             = bulletAnchor.position;
        currentBullet.transform.rotation             = bulletAnchor.rotation;

        Rigidbody rb = currentBullet.GetComponent <Rigidbody>();

        rb.velocity = Vector3.zero;
        rb.AddForce(currentBullet.transform.forward * bulletSpeed);
        // rb.velocity = Vector3.forward * bulletSpeed;
    }