Custom CharacterBody2D class, non-working methods and properties

Godot Version

4.1.3 stable


Script, extends CharacterBody2D is a custom class Player, containing player physics data (like max speed, acceleration) and some service functions like _ready() and _physics_process(). But also, there is vector() function, that returns player input vector:

func vector():
	input_direction = Input.get_vector("move_right", "move_left", "move_up", "move_down")
	return input_direction.normalized()

This function not affects parameters when called in other classes:


var player =
var player_vector = player.vector()

func _prev_vector() -> Vector2:
	var last_vector := Vector2(0, 1)
	if player_vector != Vector2.ZERO:
		last_vector = player_vector
	return last_vector

func Update(_delta):
    if player:

Output: Idle animation play (0, 1), because it don’t register any input keys. That means that it isn’t callable by this way, and this is confirmed if I put theirself vector() functions in each class:

func _player_vector() -> Vector2:
	var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down")
	print("vector updated: " + str(input_direction))
	return input_direction.normalized()


What did I miss?