Controlls wont work in f5 game preview

So im following tutorial “Your first 2D game” from GDQuest, probably bunch of you know already this one. Im stuck pretty early.

After adding mob i’ve lost ability to move character in f5 preview. First i though it was a problem of using int instead of float in mob code, i fixed it and for once controlls worked. After that one preview it doesnt work anymore. Below im publishing my code for player and mob:

extends CharacterBody2D

func _physics_process(delta):
var direction = Input.get_vector(“move_left”, “move_right”, “move_up”, “move_down”)
velocity = direction * 600.0
move_and_slide()

if velocity.length() > 0.0:
	%HappyBoo.play_walk_animation()
else:
	%HappyBoo.play_idle_animation()

extends CharacterBody2D

@onready var player = get_node(“/root/Game/Player”)

func _physics_process(delta):
var direction = global_position.direction_to(player.global_position)
velocity = direction * 300.0
move_and_slide()

I’d appreciate any help, coz im pretty new in game dev and have only basic knowlege of programming.

Have you checked if the inputs are really the problem? Try putting

if Input.is_action_pressed("move_left"):
	print("move_left")
if Input.is_action_pressed("move_right"):
	print("move_right")
# ...

right above var direction = Input.get_vector(...) in _physics_process.

Thank you for quick answer, but looks like there was probably some godot inside problem i couldnt understand. What i basically did was downloading godot again and imported same project, now it works without any problems.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.