Hello wonderful members of the community, im here to ask about the title basically.
Im making a top-down 2D action game, with a system of picking up and dropping weapons.
I could manage to make a pistol which starts on the floor, and the player can pick up and drop, this works great, but now i tried making the enemies drop their weapons when they die, using the same method for the player dropping.
This creates another "Pistol (pickup)" in the world BUT after that i always pick up "that" pistol, even if im standing on the other one.
The relevant code is the following:
var ppistol = preload("res://Pistol (pickup).tscn")
This happens when the player right clicks, while holding a pistol:
var drop = ppistol.instance()
Then when the player weapon's raycast hits an enemy:
(I didnt write a "set_position" for this one yet)
Anyways... as you can see, both time i use "getnode("/root/World").addchild(ppistol.instance())" to spawn a pistol, so im guessing this needs to be different.
The only solution i could come up with was add several vars named "ppistol1" "ppistol 2" and so on, but this is very bad code and im sure there are other, much better, ways that i havent learned yet.
Thanks in advance!