Fps Enemy

Hello, ok i have a question which i hope will lead o a simple answer.
I have my gun, movement, characters, and enemy done.
When i shoot my enemy blood splatters and he dies.
All good right?
So i try to duplicate my enemy so there is more than one. But when i shoot one enemy, they both disapear. I know why this is.
It is because my ray sensor sends a message to the property enemy. So since both are named enemy, then they both die.
My question is this: How can i make it so that i can have multiple enemies, without having to make many different logic brick setups for every single one?
Any help would be great,
Thanks, coonerboy

you need to get the name of the object that was hit by the ray and then send the message directly to that object. YOu would need to use python for this. It would be something like(writing this from memory so some of this may be wrong) this:

import GameLogic as G

cont = G.getCurrentOwner()
own = cont.owner

ray = own.sensors[‘ray’] #this is you ray sensor; name it ray
message = own.actuators[‘message’] #this is your message actuator; name it message

if ray.positive == True:
beenHit = ray.hitObject# gets the hit object and stores it in beenHit
message.target = beenHit

It’s something like this although I know it’s not 100% correct… but I am tired…

ok, so i would need to use python?

If you do use python, all you have to do is say:


I would have to look at your setup to give you anything further.

ok, i wil look into it some more. Thanks

The thing is, is that what your trying to do cant be depending on global messages. Those messages are sent to every one unless you specify else.

or you could change the property name on the duplicates…

yes, but if you are trying land a hit on one specific enemy then you have to send the message only to that object. Therefore the need for the script. Changing the name of the properties doesn’t really help that much, it actually adds another couple of steps.

Yeah I guess your right. Sorry about that I was really tired last night.