private void spawnProjectile()
{
if (attackSound)
{
AudioSource.PlayClipAtPoint(attackSound, transform.position);
}
dir = new Vector3(targetPos.x - transform.position.x, 0, 0);
distL = (transform.position - targetPos - left).magnitude;
distR = (transform.position - targetPos - right).magnitude;
toLeft = (attackRange + distL) <= distR;
bool facing = distL <= distR;
short faceDir;
if (facing)
faceDir = -1;
else
faceDir = 1;
shot = Instantiate(shotObj, transform.position + faceDir * xhalf, transform.rotation) as Projectile;
shot.Shoot(dir.normalized);
}