problem with the add-end object logic

hi i’m new her, i’m making a game in bge usin only logic bricks and i have this problem. i created an empty and using the add object actuator i made it spawn enemies. When the enemy and my character sword collide the enemy hit should disapper because of the end object actuator but it doesnt, and the empty stop spawning enemies, but it shouldnt.
can you help me solve to this problem?

Do you have the end object actuator on the empty? We really need more info, a screen-grab or .blend file would help a lot.

no the end-object actuator is on the enemy but the collision sensor is on the sword.
i’ve also tried using ray sensor instead of pyshic collision but the result is the same.
the collision sensor works, i’ve added a counter that is raised by 1 for every enemy i hit, trough object property, so i’m sure it works.
the proble is that the collision ends the wrong object i think.

how do i add the blend file

The endObject actuator always ends the object it belongs to.

I you want to end the object(s) the sensor detected you need Python to do that.

import bge

def endHitObjects():
   if not allSensorsPositive():

   for hitObject in getHitObjects():

def allSensorsPositive():
   for sensor in bge.logic.getCurrentController().sensors:
      if not sensor.positive:
         return False
   return True

def getHitObjects():
   hitObjects = []
   for sensor in bge.logic.getCurrentController().sensors:
         hitObjects += sensor.hitObjects
      except AttributeError:
   return hitObjects

Sensor(s) -> Python Module: untestedSample.endHitObjects

thank you for the quick reply Monster.
i tried your script but it doest seems to work, maybe i didn’t set it up properly
i applied an always sensor on the enemy i want to end, and a python controller with your script but nothing happens.

ok i think i found a workoround using only logic brick.
i use a radar sensor on the enemy and the end object actuator, now it works just right.
i don’t really understand why the collision sensor doesn’t work.
ok i’ve got another question to ask. i’ve parented an object to my player and put it on another layer, when i press a button it should spawn on the scene because of the add object actuator but it doesn’t.
does the parenting functuion interfere with the actuator?

What do you expect an operation is doing when it is called “end hit objects”?
What do you assume does it get these hit objects from?
What do you think an always sensor provides as hit objects?
When does it perform this operation?

This is not meat sarcastic. It is meant to help you understand what happens.

Everything ends in the questions:
WHAT should happen WHEN? = demand
WHAT happens WHEN? = what it does

I don’t really know anything about python Monster. Anyway, i think you are telling me that i should have used a collision sensor instead of the always sensor. Right?

Indeed that is right.

And the other point: as you explained above, you want to end the hit objects rather than the object that detects the collision. (otherwise your original logic would fit your needs).

There is no difference to the radar, near or ray sensors. The all provide hit objects which can be ended.

Btw. I prefer to give my code a name that let you guess what it does. They is more a joke, I think you know what I want to say with it ;).
The fire-and-forget assumption (always sensor + copy&paste the string to the controller) is nothing I can recommend.
We have this nice GUI. Why not using it :smiley:

well actually the sword was detecting the collision with a ray sensor and the end object actuator was on the enemy, but the only objects that seemed to end was the empty i use as a spawn point. that’s why i’m so confused.