How to sense when a button is interrupted?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Exoph

Set up a new var to sense when a button is released but it keeps saying it doesn’t have a set type. The functions involved are

func _physics_process(_delta: float) -> void: var is_jump_interrupted: = Input.is_jump_interrupted("jump") and velocity.y < 0.0 var direction: = get_direction() velocity = calculate_move_velocity(velocity, direction, speed, is_jump_interrupted) velocity = move_and_slide(velocity,FLOOR_NORMAL)

func calculate_move_velocity( linear_velocity: Vector2, direction: Vector2, speed: Vector2, is_jump_interrupted: bool ) -> Vector2:

var new_velocity: = linear_velocity new_velocity.x = speed.x * direction.x new_velocity.y += gravity * get_physics_process_delta_time() if direction.y == -1.0: new_velocity.y = speed.y * direction.y if is_jump_interrupted: new_velocity.y = 0.0 return new_velocity

Which line says it doesn’t have a set type?

SteveSmith | 2022-12-07 15:24

:bust_in_silhouette: Reply From: jgodfrey

Well, this can’t be what you intend…


The Input class does not have an is_jump_interrupted() function. I assume you want is_action_pressed() or is_action_just_pressed() there?

Or, maybe is_action_just_released() (based on the post’s title)

jgodfrey | 2022-12-06 22:36