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

Sorry.. OK

By, the way, t here is has another script but this to texture of flashlight:

Ok, which one of those two scripts is attached to the flashlight node?

As I said, Flashlight is responsible for the light texture and enabling the Tab key, while Flashlight Pickup is responsible for taking the flashlight and attaching it to the flashlight object node.

By the way, when I release the full-fledged first part of the game, I recommend that you play it later. Because it will be very interesting and captivating.

It doesn’t matter which one is “responsible” for what. I’m asking which one is attached to the flashlight node in the flashlight scene.

Flashlight Pickup

Ok now put those two lines at the start of interact() function

func interact(): 
	print("INTERACTED!")
	return
	# rest of your code

What gets printed when you try to pick up the flashlight?

Btw, always paste the actual code text, don’t post code screenshots.

GREAT! SIX ERRORS! IT’S I WANTED THIS? OR IT?

This has nothing to do with what we talked so far.

Sorry, I’m just a little worried that the game won’t start.

I decided to make mistakes, the only thing is that the speed scale has disappeared, but it doesn’t matter

So far, the only thing that prints is the raycast, but the object itself is not

Nothing is printed when I persistently press the “E” key next to the giant flaslight.

Let’s see your last version of this script:

extends Area3D

var flashlight

func _ready():
	flashlight = get_node("/root/" + get_tree().current_scene.name + "/player/head/flashlight")

func interact():
	print("INTERACTED!")
	return
	# rest of your code
	flashlight.picked_up = true
	queue_free()

This is changed script

No the, other script. The one that checks if raycast is colliding.

1 Like

I know this, I wrote this on purpose so that if it was possible to return to it.

extends RayCast3D

var int_text

func _ready():
	int_text = get_node("/root/" + get_tree().current_scene.name + "/UI/interact_text")

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	if is_colliding():
		print("The raycast is colliding!")
	# the rest of your stuff
		var hit = get_collider()
		if hit.has_method("interact"):
			int_text.visible = true
			if Input.is_action_just_pressed("interact"):
				hit.interact()
		else:
			int_text.visible = false
	else:
			int_text.visible = false