how do i make it so an enemy will move to an item when it is touched by that item?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By whywhyw

im making a game where you a ball with two other ball hands that float and i want to add a grab feature to it but when ever i touch the enemy my game crashes. here is the code that i used correct me please.
func _on_enemy_kill_box_body_entered(body):
if body.get(‘grab’) == ‘grab’:
move_toward(grab, grab, grab)

this ?

if body.name == "grap":
     print("bla bla")

ramazan | 2022-02-09 11:22

What error do you get? Which line causes the error?

SteveSmith | 2022-02-12 11:35

:bust_in_silhouette: Reply From: ARSHAVIR_GM

i suggests you to use groups

like this :

if body_is_in_group("ball")
   print("bla bla bla")