Pacman isn't moving in godot for some reason

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

hi, so I’ve been following this tutorial on youtube that shows how to make Pacman in the Godot Game Engine, and in 17:25 movement seems perfectly running but for me Pacman is stuck at spawn.
link for vid: https://www.youtube.com/watch?v=Nuxn13x1ePI
code:
pacman.gd:

   extends Area2D

var direction = Vector2(0,0)
var SPEED = 10
onready var walls = get_parent().get_node("walls")


func _ready():
	$AnimatedSprite.play("moving")
	position = walls.get_player_init_pos()

func _process(delta):
	if Input.is_action_pressed("ui_up"):
		direction = Vector2(0, -1)
		rotation = deg2rad(-90)
	elif Input.is_action_pressed("ui_down"):
		direction = Vector2(0,1)
		rotation = deg2rad(90)
	elif Input.is_action_pressed("ui_left"):
		direction = Vector2(-1,0)
		rotation = deg2rad(180)
	elif Input.is_action_pressed("ui_right"):
		direction = Vector2(1,0)
		rotation = deg2rad(0)

	var pos_to_move = walls.is_tile_vacant(position, direction)
	if(direction != Vector2(0,0)):
		position = position.linear_interpolate(pos_to_move, SPEED * delta)
# position = walls.is_tile_vacant(position, direction)

walls.gd:

extends TileMap

onready var half_cell_size = get_cell_size()/2

func _ready():
	pass

func get_player_init_pos():
	var pos = map_to_world(Vector2(14,23))
	pos.y += half_cell_size.y
	return pos

func is_tile_vacant(pos, direction):
	var curr_tile = world_to_map(pos)
	var next_tile = get_cellv(curr_tile + direction)
	var next_tile_pos = Vector2()
	if(next_tile == 15 or next_tile == 16 or next_tile == 17):
		next_tile_pos = map_to_world(curr_tile + direction) + half_cell_size
	else:
		next_tile_pos = pos
	return next_tile_pos

ps: those 3 tiles he selected are called for me 15, 16, 17
all help is appreciated ^-^

Can you run the script with a few prints please and copy the console output below?


    var pos_to_move = walls.is_tile_vacant(position, direction)
    printt("pos:", pos_to_move) # add this here
    if(direction != Vector2(0,0)):
        position = position.linear_interpolate(pos_to_move, SPEED * delta)


func is_tile_vacant(pos, direction):
    var curr_tile = world_to_map(pos)
    var next_tile = get_cellv(curr_tile + direction)
    printt("curr, next, dir:", curr_tile, next_tile, direction) #  and this here
    var next_tile_pos = Vector2()

DaddyMonster | 2022-01-15 10:55

:bust_in_silhouette: Reply From: theMX89

im not the best in coding, but i feel like it should be _physiks_process(delta): instead of
_process(delta):

i think its also possible that you placed packman in a wall, so maybe he isnt moving cause of that

theMX89 | 2022-01-15 07:59