Godot Version
4.2.2
Question
Hi everyone i made a top down movement controller based on this tutorial :
I get a weird bug when i put a camera node into my player node the camera with position smoothing enabled, the player can’t move, he go back to his starting position like a elastic, realy weird.
my code
extends CharacterBody2D
@export var mouvement_speed : float = 500
var character_direction : Vector2
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
character_direction.x = Input.get_axis("left", "right")
character_direction.y = Input.get_axis("up", "down")
character_direction = character_direction.normalized()
if character_direction.x > 0: %sprite.flip_h = false
if character_direction.x < 0: %sprite.flip_h = true
if character_direction:
velocity = character_direction * mouvement_speed
if %sprite.animation != "walking": %sprite.animation = "walking"
else:
velocity = velocity.move_toward(Vector2.ZERO, mouvement_speed)
if %sprite.animation != "idle": %sprite.animation = "idle"
move_and_slide()