0 votes

I have a player, I want to implement taking object from map

Initially, the object is the children of TileMap, but when I take it I try to swap the parent for this object on Player.

if obj.get_parent():
        obj.get_parent().remove_child(obj)
    add_child(obj)
print("obj = ", obj.get_path())
# out is: /root/World/Players/1/PlayerEquipment/M4  - its right

But object just staying on the player's starting position, but I want to moving this object together with player.
What is the best way to implement such a feature?

At start I had a different idea:
I tried save owner for every objects and changing they position in _physic_process(), but I thinking it is not right and I can lose performance.

asked Jan 15 in Engine by Roket (48 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.