Character2D jumps when I am clicking the pause button

Godot Version

4.3

Question

Hii, guys. Please assist here. When I click the pause button (TextureButton), the character2D jumps. I’m unsure if the program only considers the button or anywhere on the screen.

What command make your character jump? Showing your code would be userful. I’ll do a wild guess and suppose you processing that on _input, if that’s the case, try change to _unhandled_input

here is the code:

extends CharacterBody2D

pushes the player down

const GRAVITY : int = 4200

pushes the player up

const JUMP_SPEED: int = -1370

var isActive = false

func _physics_process(delta: float) → void:
if isActive and !get_tree().paused:
velocity.y += GRAVITY * delta

	# if the player is on the floor, do the following, else jump
	if is_on_floor():
		# Enable the running collisions
		if Input.is_action_pressed("ui_accept") or Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
			jump()
		else:
			$AnimatedSprite2D.play("run")
	else:
		$AnimatedSprite2D.play("jump")
	move_and_slide()

func jump():
velocity.y = JUMP_SPEED
$Jump.play()

func setActive(active: bool) → void:
isActive = active

You’re using the left mouse click as jump button, remove the or Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) and that should solve your problem.

I want to either use space or the mouse button to jump

Try puting a area node in the button and check if the mouse is inside that area, in your if statement where there’s the jump function, add a code that checks if the mouse is inside said area if so run the jump function, else do nothing.

Ps. Not the best solution, but it works as a temporary fix

So you need to move this check for the _unhandled_input callback

Yeah that works but I am trying for an alternative, but if there’s none ill use it.