Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | deaton64 |
Hello,
I’ve got a bullet that’s an Area2D that collides with a KinematicBody2D and I can get the node it collides and call a function in that node to set the damage.
I want to do the same thing with the bullet colliding with another Area2D node.
I’ve set the Area2D node name the same name as the root node of the object, so the code below works.
var name = area.get_name()
var mynode = get_tree().get_root().find_node(name,true,false)
mynode.take_damage(_damage)
but I don’t like it and feel that the search could be slow at times (maybe from what I’ve read).
If there’s no other way, then I was going to get the other object to check what it’s been hit by and react to what ever a global bullet damage value may be.
Is there a better way to do this?
Thanks,
David