Problem with item in Godot3D. The game "Butterfly Kindergarten" Part 2

Godot Version

Godot Engine 3D 4.6

Question

In the last post, I was helped to make it so that the rays of the rake could determine the object and its interaction with it, but this is not the end. The next thing I need is for the “E” button to work when pressed, and for the object to disappear and move in the hand. I also want the ray of the rake to remove the “E” letter when the player moves away.This will help me create commands for interacting with doors and other objects. I might also review the video tutorials, because it might have been a little easier than I thought, and I might have missed something.

The problems that cause the game not to start are small and simple

E 0:00:05:920 interact: Invalid assignment of property or key ‘picked_up’ with value of type ‘bool’ on a base object of type ‘null instance’.

E 0:00:02:649 pickup_flashlight.gd:6 @ _ready(): Node not found: “/root/level/Player/head/flashlight” (absolute path attempted from “/root/level/Flashlight”).

flashlight.picked_up = true
flashlight = get_node(“/root/” + get_tree().current_scene.name + “/Player/head/flashlight”)

Definitely do that first.

When I read the error, I noticed that it said “null instance.” How could this happen, and why does the flashlight consider it a null instance? The second one is also difficult. I think I wrote the path correctly, without any errors, but for some reason the script can’t find the path to the flashlight, even though I specified that the flashlight will work if the player picks it up.

The most interesting thing is that these errors were introduced under the Interact and Ready functions

get_node() returns null if the path doesn’t point to a valid node. Your second error is most likely causing the other one.

Make sure the path is correct, including the capitalization of all node names.

1 Like

Thank you very much, it turned out that the player in the scene was named with a small letter instead of a capital letter. I fixed it, and everything worked.