The function itself I don't think is of relevance, but I'll put it here anyway:
if GV.curr_player.idle and GV.curr_player.is_on_floor():
GV.curr is a KinematicBody2D with a split and merge function that involves replacing nodes with other nodes. The weird thing is this script works fine when called in
_process using an
Input.is_action_just_pressed key. It even works with my GUI button if I call:
if $Pathtobutton.pressed: player_toggle_mode()
If I directly connect the
button_up, the function misbehaves (explaining how it misbehaves would be very tricky, basically the function calls for new nodes to be introduced and when called this way their positions are wrong).
I would guess it has something to do with the stage at with Input from Control node buttons are taken, but I'm really stumped.