- Edited
I create objects every seconds with code and they have random position but someone's body_entered works, someone's does not work. How can i fix it ?
I create objects every seconds with code and they have random position but someone's body_entered works, someone's does not work. How can i fix it ?
We need more information to help you.
Can you upload a .zip containing a minimal project that illustrates the problem?
The problem is that you are checking for the name "Sushi", but only some of them have that name. See the attached image.
A better way is to use groups.
In Area2D.gd, change:
var object = sushi.instantiate()
to:
var object = sushi.instantiate()
object.add_to_group("sushi")
In space.gd and stick,gd, change:
if body.name == "Sushi":
to:
if body.is_in_group("sushi"):
Thank you for everything. it works and most important thing is that i understand where is my wrong.
You're welcome.
Also, the way that you are generating sushi's is strange. Instead of using a recursive function call (createSushi calls itself), it would be clearer to add a Timer that runs every two seconds and whose timeout signal creates a sushi.