nonexistent function but everything by tutorial

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

everything is as it says in the title. I have no experience in creating an inventory and I found a video cycle with an explanation of what needs to be done. actually, the video itself is below. the problems start at 12: 15, because the code considers the pick_up_item function non-existent when i’m trying to interact.
I’m sorry if this format of the question offends you, but I really can’t find a solution. I will be glad of any help, have a good day
below will be the code and video itself

player (that one part):

func _input(event):
	if Input.is_action_just_pressed("takeitem"):
		if $itemdrop.itemsinrange.size() > 0:
			var pickitem = $itemdrop.itemsinrange.values()[0]
			pickitem.pick_up_item(self) #пофиксь пик ап итем пж, оно не видит функцию в сцене drop((((((
			$itemdrop.itemsinrange.erase(pickitem)

drop:

extends KinematicBody2D

const ACCELIRATION = 700
const MAX_SPEED = 95
var velocity = Vector2.ZERO

var itemname
var player = null
var being_picked_up = false

func _ready():
	itemname = "Монстро-конфета"
	
func _physics_process(delta):
	if being_picked_up == true:
		var direction = global_position.direction_to(player.global_position)
		velocity = velocity.move_toward(direction * MAX_SPEED, ACCELIRATION * delta)
		
		var distance = global_position.distance_to(player.global_position)
		if distance < 10:
			PlayerInv.add_item(itemname, 1)
			queue_free()
	velocity = move_and_slide(velocity, Vector2.UP)
	

func pick_up_item(body):
	player = body
	being_picked_up = true

Verify if the method exists in the object class by using the function below . The path to methods_log.txt file is printed at the end of this snippet.

Open the log.txt file with a text editor and see if the function is there. (Make sure your app is not running)

func _input(event):
	if Input.is_action_just_pressed("takeitem"):
		if $itemdrop.itemsinrange.size() > 0:
			var pickitem = $itemdrop.itemsinrange.values()[0]

			#### Code to list all methods of an object to a methods_log.txt file
                    methods_log(pickitem)
	                print("Logs dir:",OS.get_user_data_dir())	

			pickitem.pick_up_item(self) #пофиксь пик ап итем пж, оно не видит функцию в сцене drop((((((
			$itemdrop.itemsinrange.erase(pickitem)


func methods_log(obj):
	var methods: Array
	for m in obj.get_method_list():
		methods.append(m.name)
	methods.sort()
	
	var write_log = File.new()
	write_log.open("user://methods_log.txt", File.WRITE)
	write_log.store_line("Class:"+obj.get_class())
	for m in methods:
		write_log.store_line(m)
	write_log.close()

wyattb | 2021-06-27 16:57

:bust_in_silhouette: Reply From: theMX89

i would try it with the “_process(delta):” func instead of the _input func

it gives the same result(
and I noticed that any click on the “takeitem” button breaks the game
but still thanks for trying

pafos_kota | 2021-06-26 16:58