Multiple Enemys

Hello everyone,

i made a little game with some enemys i want to kill. I have one enemy on Layer 2 that is spawned in my Layer 1 (where the game is happening) and i can kill him (till here it works)

If i spawn more than one enemy in my scene i’m not able to attack or kill them anymore.
For the spawning i use a simple addObject function. Every enemy that is spawned, after the first one,is the exact same to the first one but i can’t hurt them :frowning:

If somebody has an idea please answer :slight_smile:

Could you please upload a .blend showing the problem? I can’t re-create it. What method are you using to ‘kill’ the enemies?

My guess is the health property is the same for all of them. If you kill one, the health is likely below zero, and then they can’t die. Just a guess

By the looks of the description I’d say the same, maybe you’re instantiating the model but not the properties, so they are no reset for each new enemy.

Are you adding a reference of instance? I add objects using the logic actuator so I don’t know exactly how to even instance instead of reference…

This is the build in victim-protection. If the protection system identifies a killer, the protection saves the survivors ;). It looks more effective than temporary banning the killer in electronic jail :ba:.

Seriously: As my previous posters wrote, you need to separate the data space of each single instance. E.g. do not use global dict or similar shared resources. Better store data at the object itself (in properties).

As we do not know your implementation it is hard to guess your specific design flaw. I suggest to post a test blend (without textures and other unnecessary data). So we can have a look. I’m sure it is pretty easy to be identified and get fixed.

I have uploaded a example .blend for you

In game you are the blue cube and you have to be near the red cube and click to harm him (solved with phythonscript “enemy.py”)
if you kill the 1st enemy two other will spwan but if you kill one of them the other dies with him. :frowning:

Don’t host there, It just tried to push me malware…

PasteAll.org

When you are near your enemy, you send a message to tell the enemy to subtract health, right?
Well, the message goes to all the enemies, so they all subtract health regardless of whether they’re the one you’re close to.

I solved it :slight_smile:

I just recreated my code and tryed to think logicly …

  • The error usually sits in front of the screen