I am sooo confused

Godot Version

Godot 4.2.1


	if karakter != null:
		var karakter_pozisyon = karakter.position
		var y_koordinati = karakter_pozisyon.y
		var x_koordinati = karakter_pozisyon.x
		print("Karakter Pozisyonu: ", karakter_pozisyon) 
		print("X Koordinatı: ", x_koordinati)    
		print("Y Koordinatı: ", y_koordinati)    
		print("Karakter düğümü bulunamadı.")

Neden düğüme ulaşamıyorum? ( $player ile de ulaşamıyorum)

you declared script file name,…

@onready var karakter = $CharacterBody2D

your script is attached to player

you can call only self.position or position

1 Like

Because by calling $CharacterBody2D in “player” node, we expect there to be a child node that has name of “CharacterBody2D”. In your case, player is itself CharacterBody2D, so i suspect you wanted to get reference to the node you are running the script on. One way to do it is to use self keyword. Or if you are working with methods of this class in itself, you can omit self entirely

move_and_slide() # Does same stuff as the above line

self is still useful to get reference to self to use it as some outside method parameter, or other use-cases where you want to have yourself as a variable.

1 Like