How to make a system where i drop object A on object B and get object C?

Godot 4

I basically wanted to make a system where my player picks up Object A, walks over to Object B and drops it on A, then both disappear, and a new Object C is in their place. I managed to get the pick/drop system working, but for some reason idk how to actually make A and B disappear and make C appear. any help or tutorials would be great!

the tutorial i used for the pick/drop system here

a gif is attached below of the pick and drop system i got working

screen-recording(13)

make to both of them an area2D node(give them other names, i will call them areaA and areaB) and make a childNode of the area and it is CollisionShape2D make a shape to the egg i guess. and go to the code of eggA:

first go to the the node of the area2D(not inspector) and go to the signal when area entered accept it again and the signal will be on your code and looks like this:

func _on_AreaA_area_entered(area: Area2D) → void:
pass

delete the pass and put this instead:

func _on_damage_zone_area_entered(area: Area2D) → void:
if area.name == “AreaB”:
$egg-C.show()
else:
$egg-C.hide()

i hope it helped :wink:

thank you for replying!

they are area2d nodes, so this should work, but any chance you know how to remove them from the scene entirely to instantiate a new object?

yep here replace the last code i gave to you to this:

func _on_damage_zone_area_entered(area: Area2D) → void:
if area.name == “AreaB”:
$egg-C.queue_redraw()
else:
$egg-C.queue_free()

warning! queue_free() deletes the node and queue_redaw() puts the node back

had to make some adjustments to the code after connecting the signal, but i basically just needed the signal and (area: Area2D) part. thank you for ur help <3

1 Like

i didn’t expect that, ima a mid-begginner

1 Like