Help. Add random object using random actuator but two objects are add instead.

I tried to spawn random object using random actuator, but when I spawn it using keyboard, it spawn two objects instead of one. I have no idea why. But my guess that actuator is being activate multiple times.

Add 2 objects .blend (540 KB)

Thank you

Try setting your sensor to TAP.

Setting the sensors to tap does not fix the problem, if you put " and Property == True" in the expression controllers the problem disappears.

Add 2 objects .blend (489 KB)

Thank you I will try it out, but why does this cause a problem.

The problem is that you use an expression controller. You would get the same problem with the Python controller too.

A lot of freedom means a lot of responsibility. As much you customize a brick as much you have to do. In your case it means … do not forget check the sensor evaluation state(s).

The better alternative is to use one sensor for each number + and + actuator. If you want to save on logic bricks (which makes sense when exceeding a certain number of objects) you better use the dynamic power of Python. Again, do not forget to check the sensor evaluation states.


def activateNthActuator(controller):
   if not allSensorsPositive():
      return 

   sensor = findPropertySensor()
   owner = controller.owner
   index = owner[sensor.propName]
   
   actuator = controller.actuators[index-1]
   controller.activate(actuator)

def allSensorsPositive():
   ... your part

def findPropertySensor():
   ... your part