Ejemplo n.º 1
0
    public void ShootFromTurret(bool left, string turretName)
    {
        playerShipTurret            = playerShipBody.transform.Find(turretName).gameObject;
        playerTurretShootPoint_left = playerShipTurret.transform.Find("PlayerTurretBarrelLeft").transform.Find("PlayerTurretShootPoint").gameObject;
        if (left == false)
        {
            playerTurretShootPoint_right = playerShipTurret.transform.Find("PlayerTurretBarrelRight").transform.Find("PlayerTurretShootPoint").gameObject;
        }

        float   projectileAngleInRad = transform.Find("PlayerShipBody").transform.Find(turretName).transform.eulerAngles.z *Mathf.Deg2Rad * -1;
        Vector3 projectilePosition   = playerTurretShootPoint_left.transform.position;

        if (!left)
        {
            projectilePosition = playerTurretShootPoint_right.transform.position;
        }
        PlayerProjectile projectile = Instantiate(playerProjectile, projectilePosition, playerShipTurret.transform.rotation) as PlayerProjectile;

        projectile.GetComponent <SpriteRenderer>().sortingOrder = 2;
        projectile.SetupProjectile(turretName, projectileAngleInRad);
    }