Previously my items were relative to the player by node hierarchy. But for items like bombs this is not ideal so i tried to add the items to the world scene, but when i try to adjust the position of the item to the players position it doesnt work and i see the sword in the top left corner of the screen the worlds origin.
Entity Script
func use_item(item):
var newitem = item.instance()
newitem.own = self
newitem.global_position = global_position
#not setting the position of the item correctly
newitem.add_to_group(str(newitem.get_name(), self))
get_node("..").add_child(newitem)
if get_tree().get_nodes_in_group(str(newitem.get_name(),self)).size() > newitem.maxamount:
newitem.queue_free()
Sword Script
func _ready():
type = own.type
$anim.connect("animation_finished",self,"destroy")
$anim.play(str("swing",own.spritedir))
if own.has_method("state_swing"):
own.state = "swing"
func destroy(animation):
if own.has_method("state_swing"):
own.state = "default"
queue_free()
It seems like it should work but with an engine like godot there could be several reasons why a certain thing is not working.
https://github.com/MonkeyToiletLadder/wendingo
could it be that in my animation player i set the sword positions as key frames and thats why its not working?