I need the help of my item not becoming collected as an item source

Godot Version

4.6

Question

my ItemMagnet is not tell the ItemPickup what it needs to do when i pick up and item

class_name ItemPickup extends CharacterBody2D

signal picked_up

@export var item_data : ItemData : set = _set_item_data

@onready var area_2d: Area2D = $Area2D
@onready var sprite_2d: Sprite2D = $Sprite2D
@onready var audio_stream_player_2d: AudioStreamPlayer2D = $AudioStreamPlayer2D


func _ready() -> void:
	_update_texture()
	if Engine.is_editor_hint():
		return
	area_2d.body_entered.connect( _on_body_entered )


func _physics_process(delta: float) -> void:
	var collision_info = move_and_collide( velocity * delta )
	if collision_info:
		velocity = velocity.bounce( collision_info.get_normal() )
	velocity -= velocity * delta * 4


func _on_body_entered( b ) -> void:
	if b is Player:
		if item_data:
			if PlayerManager.INVENTORY_DATA.add_item( item_data ) == true:
				_item_picked_up()
				print_debug( "ItemPickup" )
	pass


func _item_picked_up() -> void:
	area_2d.body_entered.disconnect( _on_body_entered )
	audio_stream_player_2d.play()
	visible = false
	picked_up.emit()
	await audio_stream_player_2d.finished
	queue_free()
	pass


func _set_item_data( value : ItemData ) -> void:
	item_data = value
	_update_texture()
	pass


func _update_texture() -> void:
	if item_data and sprite_2d:
		sprite_2d.texture = item_data.texture
	pass


var items : Array[ItemPickup] = []
var speeds : Array[float] = []
var printed = false

@export var magnet_strength : float = 1.0
@export var play_magnet_audio : bool = false

@onready var audio: AudioStreamPlayer2D = $AudioStreamPlayer2D



func _ready() -> void:
	area_entered.connect( _on_area_enter )
	pass


func _process(delta: float) -> void:
	for i in range( items.size() -1, -1, -1 ):
		var _item = items[i]
		if _item == null:
			items.remove_at( i )
			speeds.remove_at( i )
			print_debug( "item was removed" )
			pass
		elif _item.global_position.distance_to( global_position ) > speeds[i]:
			speeds[i] += magnet_strength * delta
			_item.position += _item.global_position.direction_to( global_position ) * speeds[i]
			if !printed:
				print_debug("item.position")
				printed = true
		else:
			_item.global_position = global_position
	pass


func _on_area_enter( _a : Area2D ) -> void:
	if _a.get_parent() is ItemPickup:
		var _new_item = _a.get_parent() as ItemPickup
		items.append( _new_item )
		speeds.append( magnet_strength )
		_new_item.set_physics_process( false )
		if play_magnet_audio:
			audio.play(0)
		print_debug( "_on_erea_enter" )
		pass
	pass

What is the ItemMagnet, your second script? What do you expect to happen versus what really happens?

It doesn’t seem like this block does anything with the ItemPickup, do you need to call _item_picked_up on it?

the ItemMagnet script is where the item gets picked up by the ItemPickup script. My ItemPickup script is not being called by the ItemMagnet script. I have fallowed the video “Item Magnet // E27 // Make a 2D Action & Adventure RPG in Godot 4” from “Micheal Games”.

I dont know why but because I’m at a lost with my ItemPickup not wanting to work from the ItemMagnet script but I’m able to pick up items. The items are getting picked up but never fallow through to the ItemPickup script.

I still dont know how to get the ItemMagnet to talk to the ItemPickup

Items get picked up but not passing to through the ItemPickup