The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

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 pickupitem 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((((((


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)
    velocity = move_and_slide(velocity, Vector2.UP)

func pick_up_item(body):
    player = body
    being_picked_up = true
Godot version 3.3.2
in Engine by (32 points)

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
                    print("Logs dir:",OS.get_user_data_dir())   

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

func methods_log(obj):
    var methods: Array
    for m in obj.get_method_list():

    var write_log ="user://methods_log.txt", File.WRITE)
    for m in methods:

1 Answer

0 votes

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

by (224 points)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.