Godot Version
Godot 4
Question
I’m trying to make a Grid-based Movement system similar to the one found in Pokemon Mystery Dungon, however when moving Diagonally from a stand-still unless you manage to hit both inputs frame perfectly you’ll move in one direction instead then move diagonally while holding, how can I improve the consistency of being able to move diagonally initially?
Heres all the relevant code, its not in the fancy formatted box because I don’t know how to do that
if GridMode and not moving:
input_dir = Vector2.ZERO
# Detects the imput from the player
if Input.is_action_pressed("ui_up"):
input_dir.y -= 1
if Input.is_action_pressed("ui_down"):
input_dir.y += 1
if Input.is_action_pressed("ui_left"):
input_dir.x -= 1
if Input.is_action_pressed("ui_right"):
input_dir.x += 1
# If the vector isn't zero, checks if the movement will be valid before calling the move function
if input_dir != Vector2.ZERO:
if check_tile():
move()
func move():
if input_dir:
if moving == false:
moving = true
var tween = create_tween()
tween.tween_property(self, “position”, position + input_dir*tile_size, GridModeSpeed)
tween.tween_callback(move_false)