extends KinematicBody2D export (int) var speed = 200 var velocity = Vector2() var target = Vector2() var prev_tile = null # Hex coords of previous tile var cur_tile = null # Hex coords of current tile func get_input(): velocity = Vector2() if Input.is_action_pressed("walk_right"): velocity.x += 1 if Input.is_action_pressed("walk_left"): velocity.x -= 1 if Input.is_action_pressed("walk_down"): velocity.y += 1 if Input.is_action_pressed("walk_up"): velocity.y -= 1 velocity = velocity.normalized() * speed func _physics_process(_delta): velocity = position.direction_to(target) * speed if position.distance_to(target) > 5: velocity = move_and_slide(velocity) var tile = Globals.WorldToHex(position) if tile != cur_tile: prev_tile = cur_tile cur_tile = tile # Called when the node enters the scene tree for the first time. func _ready(): position = Vector2(0,0) # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta): # pass