Esempio n. 1
0
    public void SpawnProjectile(Transform muzzle)
    {
        if (projectiles.Count >= weapon.maxAmountOfProjectiles)
        {
            return;
        }

        if (weapon.projectilePrefab)
        {
            GameObject          projectile    = Instantiate(weapon.projectilePrefab, muzzle.position, Quaternion.identity) as GameObject;
            ProjectileBehaviour projectileBih = projectile.GetComponent <ProjectileBehaviour>();

            projectileBih.SetOwner(owner);
            projectileBih.OnProjectileDestroyed += RemoveProjectile;
            projectiles.Add(projectile);
        }
        else
        {
            Debug.LogWarning("No projectile prefab ");
        }
    }