Problems creating a Shooting game using the "Spawn Object by Name" node

Hi…
I’ve been trying to solve the following problem for the last 3 days:
I created bullets to shoot at an enemy using the “Spawn Objects by name” node. If I fire one shot at a time, letting the bullet (object) disappear from the screen, everything works correctly. However, if I fire consecutive shots, the previous object stops their movement (“Translate” node) and remains stationary on the screen, while the new bullet continues to move. If I press it again, this one will stop too while a new bullet is created. This is driving me crazy!! Does anyone know what it could be??
Thanks a lot

If you could provide a screenshot of any relevant node trees that might help us diagnosis the problem.

Hi, don’t worry anymore, the solution of your problem is simple. What happens every time you trigger a new spawn object the reference of your object changes. So the actual spawn does what you describe it needs to do. What you need to do instead is put all that code after the spawn in a new trait assigned to the object you are using in the spawn node. In that way, every spawned object will have the desire behavior on its own. This is a very common problem we all had when we started. I remember perfectly when it happened to me, so good luck with it!

Thank you very much PurpleOn and Lapiznegro,
Here are some images of what I’m talking about, with the guidance given by Lapiznegro.
The behavior changed but the problem remains. Now, the first shot goes out and the second one stops at “Empty” and I can’t shoot anymore. The feeling is that copies of the “Bullet” object cannot live together as isolated objects…
What am I doing wrong? It’s not easy. I can’t sleep anymore!!

It worked out!!

… And I don’t know exactly why it didn’t work the other way.
I used a “Self Object” node instead of using the object name (and it worked!!)
Thanks for the tip Lapiznegro!!

1 Like

good! yes, because you can use self object or nothing… both refer to the same instance. If you use the object from blender, it refers to that instance. You can keep track of instances using the uid which is an unique identifier. In nodes you can use get uid node.