Rate my first state maching

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

enum {
	IDLE,
	RUN,
	JUMP
}

var gravity = 10
var speed = 10000
var jump = 200
var state = RUN
var motion = Vector2.ZERO
var x_input

func _physics_process(delta):
	x_input = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
	motion.y += gravity
	
	match state:
		IDLE:
			print("idling")
			inputstuff()
		RUN:
			print("running")
			move(delta)
		JUMP:
			print("jump")
			_jump()
			
	motion = move_and_slide(motion, Vector2.UP)

func inputstuff():
	if x_input != 0:
		state = RUN
	if Input.is_action_pressed("ui_up"):
		state = JUMP

func move(delta):
	if x_input != 0:
		motion.x = x_input * speed * delta
	else:
		state = IDLE
	if Input.is_action_pressed("ui_up"):
		state = JUMP

func _jump():
	if is_on_floor():
		if Input.is_action_pressed("ui_up"):
			motion.y = -jump
	if x_input != 0:
		state = RUN
	else:
		state = IDLE

this is the first time I made a state machine and it looks garbage but it actually works. I watched a bunch of tutorials but It’s just hard to understand since I just started around a week ago, the one made by heartbeast was the only one I understood. Any recommendations on getting better at this.