Jumping isn't working only with controller?

Version 4.2.2

My jump mechanic uses the same input map as keyboard and everything and as far as i know it’s all setup right i just don’t know why its not working specifically on controller. Any ideas???

if event.is_action_pressed("jump"):
		if $RayCast3D.is_colliding() or wallstick == true:
			apply_central_impulse(Vector3.UP * 16.0)
			self.gravity_scale = 3.5
			can_dash = true
			jumped = true
			wallstick = false
			if isCrouching == false:
				$Character/AnimationPlayer.play("Jump")
				
		elif jumped == true:
			if isCrouching == false:
				if doublejump == false:
					$Character/AnimationPlayer.play("Double Jump")
					apply_central_impulse(Vector3.UP * 16.0)
					self.gravity_scale = 3.5
					doublejump = true

Use Input.is_just_pressed("jump). Event does not include controller events

This is not true, _input functions also handle controller inputs.

1 Like

Yeah just tested and didn’t work, like if i’m not mistaken i t was working perfectly fine but just rn its not

There also isn’t such a method, the actual method is is_action_just_pressed

Could you post more of the lines before this script? Could you do a minimal input test to see if your controller is working?

func _input(event: InputEvent) -> void:
    if event.is_action_pressed("jump"):
        print("controller works!")

Yeah every other input and everything works fine so the controller is working fine

and here is the code from before the jump

extends RigidBody3D
class_name Player
#```
var respawn_position := global_position

var mouse_sensitivity := 0.001
var controller_sensitivity := 0.070
var DASH_SPEED := 1000
var can_dash: bool = false
var walkingspeed= 1200
var crouchspeed = 600
var jumped = false
var doublejump = false
var currentspeed = walkingspeed

var isCrouching = false
var isNeutral = true
var isdashing = false
var groundpounding = false
var onground = false
var wallstick = false


@onready var character := $Character
@onready var twist_pivot := $TwistPivot
@onready var pitch_pivot := $TwistPivot/PitchPivot
@onready var timer = $dropTimer

func _ready() -> void:
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
	
	
func _process(delta: float) -> void:
	var input := Vector3.ZERO
	if groundpounding == false:
		if wallstick == false:
			input.x = Input.get_axis("move_right", "move_left")
			input.z = Input.get_axis("move_back", "move_forward")
			apply_central_force(twist_pivot.basis * input * currentspeed * delta)
			#if $RayCast3D.is_colliding():
				#if isCrouching == false:
					#if isdashing == false:
						#if jumped == false:
						
							#var is_moving: bool = not input.is_zero_approx()
							#if is_moving:
								#$Character/AnimationPlayer.play("Run")
							#elif $Character/AnimationPlayer.current_animation == "Run":
								#$Character/AnimationPlayer.play("Idle")
						
		var twist_pitch : Vector2 = -Input.get_vector("look_left", "look_right", "look_down", "look_up") * controller_sensitivity
		apply_camera_input(twist_pitch.x, twist_pitch.y)
		
	
	if $RayCast3D.is_colliding():
		if isCrouching == false:
			if wallstick == false:
				if isdashing == false:
					onground = true
					can_dash = true
	
	if Input.is_action_just_pressed("dash") and can_dash:
		if $RayCast3D.is_colliding():
			apply_central_impulse(Vector3.UP * 2.0)
			onground = true
			can_dash = false
			apply_central_impulse(twist_pivot.basis * input * DASH_SPEED * delta)
			timer.start()
			self.gravity_scale = 0
			isdashing = true
			#$Character/AnimationPlayer.play("Dash")
			
		else:
			onground = true
			can_dash = false
			apply_central_impulse(twist_pivot.basis * input * DASH_SPEED * delta)
			timer.start()
			self.gravity_scale = 0
			isdashing = true
			#$Character/AnimationPlayer.play("Dash")
		
	if Input.is_action_pressed("crouch"):
		if $RayCast3D.is_colliding() == false:
			if jumped == true:
				if isCrouching == false:
					#$Character/AnimationPlayer.play("Ground Pound")
					apply_central_impulse(Vector3.DOWN * 3.0)
					groundpounding = true

		elif $RayCast3D.is_colliding():
			if isCrouching == false:
				movementStateChange("crouch")
				currentspeed = crouchspeed

		
	elif not Input.is_action_pressed("crouch") and $"Crouch Raycast".is_colliding() == false:
		if isCrouching == true:
			movementStateChange("uncrouch")
			currentspeed = walkingspeed


	if Input.is_action_just_pressed("ui_cancel"):
		Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
		
	
	if not input.is_zero_approx():
		var move_direction = twist_pivot.basis * input
		var align = character.transform.looking_at(character.transform.origin - move_direction)
		character.transform = character.transform.interpolate_with(align, delta * 20.0)

func _on_drop_timer_timeout():
	if wallstick == true:
		pass
	else:
		self.gravity_scale = 3.5
		isdashing = false


func _unhandled_input(event: InputEvent) -> void: 
	if event is InputEventMouseMotion:
		
		if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
			var twist: float = - event.relative.x * mouse_sensitivity
			var pitch: float = event.relative.y * mouse_sensitivity
			apply_camera_input(twist, pitch)
	
	

func apply_camera_input(twist_input: float, pitch_input: float) -> void:
	twist_pivot.rotate_y(twist_input)
	pitch_pivot.rotate_x(pitch_input)
	pitch_pivot.rotation.x = clamp(pitch_pivot.rotation.x, 
	deg_to_rad(-20), 
	deg_to_rad(20)
	)



func _unhandled_key_input(event):

	if event.is_action_pressed("jump"):
		if $RayCast3D.is_colliding() or wallstick == true:
			apply_central_impulse(Vector3.UP * 16.0)
			self.gravity_scale = 3.5
			can_dash = true
			jumped = true
			wallstick = false
			#if isCrouching == false:
				#$Character/AnimationPlayer.play("Jump")
				
		elif jumped == true:
			if isCrouching == false:
				if doublejump == false:
					#$Character/AnimationPlayer.play("Double Jump")
					apply_central_impulse(Vector3.UP * 16.0)
					self.gravity_scale = 3.5
					doublejump = true