jump and shoot

Hello. My problem is not jumping when the character shoots and runs to the left. Without shooting, the character jumps normally, regardless of the side he is running. But when I shoot while running to the left, the character does not jump (to the right, everything works normally).please help

public float speed;
public float jumpForce;
public GameObject bulletPrefab;
public Transform shotSpawner;

private Animator anim;
private Rigidbody2D rb2d;
private bool facingRight = true;
private bool jump;
private float hForce = 0;
private bool onGround;
public Transform groundCheck;
public float checkRadius;
public LayerMask whatIsGround;
private bool lookingUp;
private bool lookingDown;
private float fireRate = 0.35f;
private float nextFire;

private bool isDead = false;

void Start()
{
rb2d = GetComponent();
anim = GetComponent();
}

void Update()
{
if (!isDead)
{
if (!onGround)
{
anim.SetBool(“Jump”, true);
}

if (onGround)
{
anim.SetBool(“Jump”, false);
}

if (Input.GetButtonDown(“Jump”) && onGround)
{
jump = true;
}

else if (Input.GetButtonUp(“Jump”))
{
if (rb2d.velocity.y > 0)
{
rb2d.velocity = new Vector2(rb2d.velocity.x, rb2d.velocity.y * 0.5f);
}

}

if (Input.GetButton(“Fire1”) && Time.time > nextFire)
{

nextFire = Time.time + fireRate;
anim.SetBool(“Shoot”, true);
GameObject tempBullet = Instantiate(bulletPrefab, shotSpawner.position, shotSpawner.rotation);
if (!facingRight && !lookingUp)
{
tempBullet.transform.eulerAngles = new Vector3(0, 0, 180);
}
else if (!facingRight && lookingUp)
{
tempBullet.transform.eulerAngles = new Vector3(0, 0, 90);
}
if (!facingRight && lookingDown && hForce < 0)
{
tempBullet.transform.eulerAngles = new Vector3(0, 0, 205);
}
else if (!facingRight && lookingUp && hForce < 0)
{
tempBullet.transform.eulerAngles = new Vector3(0, 0, 155);
}
if (!onGround && lookingUp)
{
tempBullet.transform.eulerAngles = new Vector3(0, 0, 90);
}
else if (!onGround && lookingDown)
{
tempBullet.transform.eulerAngles = new Vector3(0, 0, -90);
}

}
if (Input.GetButtonUp(“Fire1”))
{
anim.SetBool(“Shoot”, false);
}

lookingUp = Input.GetButton(“Up”);
lookingDown = Input.GetButton(“Down”);

anim.SetBool(“LookingUp”, lookingUp);
anim.SetBool(“LookingDown”, lookingDown);

}
}

private void FixedUpdate()
{
if (!isDead)
{
onGround = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);

hForce = Input.GetAxisRaw(“Horizontal”);

anim.SetFloat(“Speed”, Mathf.Abs(hForce));

rb2d.velocity = new Vector2(hForce * speed, rb2d.velocity.y);

if (hForce > 0 && !facingRight)
{
Flip();
}
else if (hForce < 0 && facingRight)
{
Flip();
}

if (jump)
{
anim.SetBool(“Jump”, true);
jump = false;
rb2d.AddForce(Vector2.up * jumpForce);
}
}
}

void Flip()
{
facingRight = !facingRight;

Vector3 scale = transform.localScale;
scale.x *= -1;
transform.localScale = scale;
}

You should use the script formatting to paste your code, like this

else if (Input.GetButtonUp("Jump"))
{
if (rb2d.velocity.y > 0)
{
rb2d.velocity = new Vector2(rb2d.velocity.x, rb2d.velocity.y * 0.5f);
}

Anyway the problem is there, you are checking if the player velocity is greater than 0 then jump. Gameobjects in the world move on 2 axis, X and Y. The positive (> 0) of the X is the right, the negative (< 0) is the left. For the Y axis is similar but with up and down. Anyway with your script you only allow to jump when the player is moving to the right (velocity > 0). If you want the player to always jump (also if it isn’t moving) don’t check the velocity but just if the button jump is pressed. If you want the player to jump only when moving (velocity != 0) you can add another "else if (rb2d.velocity < 0) or just use (rb2d.velocity != 0). The code is messy, i suggest you to take a look how to write cleaner code because it’s better for you and for those who read your codes to help you. Also do some debugging, you could insert a debug.log inside

if (jump)
{
anim.SetBool("Jump", true);
jump = false;
rb2d.AddForce(Vector2.up * jumpForce);
}

to see if the condition is verified when going left or not so you know if it’s a problem on the boolean or just a problem with coords/forces

Sorry, maybe I got it wrong.
The character jumps without any problems when I go to the left.
The character does not want to jump when, apart from running to the left, I shoot.
The strange thing is that when I stand facing left and not run, I can shoot and jump. The problem only occurs while running.