Adding multiple objects into a scene like a particle system.

Hi im wanting to emit a random number of objects into a scene (like a particle system) when the character runs into the object. Thought of using an Edit Object Actuator to add an object and run a loop in a script to activate it multiple times. However i think activate is not really “triggering” it more of just turning it on as it were ‘making it active’.

So loop runs and outputs info but only 1 object added.

Anyone have any ideas? I did get my code to send a message back to a TRUE pulsed message sensor but then i couldnt control the linear velocity at which the objects came flying out as.

Psudo code->

X=Random integer

while x > 0:
    added.applyMovement((random number,random number,random number),1)

Ok it works now. Only issue is that the object the character collides with is there untill all objects have popped out. So there is a tiny sense of being obstructred. Not a biggy at this point in time. I think if i want a seamless collision and explode i would need to use two objects perhaps? one to emit and one to detect collision…hmmm id prefer not though. I’ll leave post unsolved for a bit longer incase anyone has any idea about the collision issue without using a two object solution.

from bge import logic
import bgl
import bpy
import random

con = logic.getCurrentController()
obj = con.owner
addPObjectA = con.actuators['Add_PObjectA']
col = con.sensors['PObjectBCol']

def update():
    if col.positive == True:
        obj['colCheck'] = True

    if obj['colCheck'] == True:
        print('updating velocity to:' random.randint(-10,10))
        addPObjectA.linearVelocity = (random.randint(-10,10),random.randint(-10,10),random.randint(5,15))
        obj['rubbishCount'] = (obj['rubbishCount'] + 1)

def delete():

if obj['rubbishCount'] == obj['rubbishTotal']:
elif obj['rubbishCount'] < obj['rubbishTotal']:

I would not use the edit object actuator,

instead use python,

added.worldLinearVelocity = (random.randint(-10,10),random.randint(-10,10),random.randint(5,15))

you can add more then one item in a single frame this way,

true, yes i noticed that a few people were using addObject to current scene. Is there a reason for this?
As i can adjust multiple objects by having the Object property of the actuator update as well as the velocity or is this a more process intensive way?
I must say i prefer the way you suggested :stuck_out_tongue: just looks tidier and i would rather not use so many logic bricks and noodles :stuck_out_tongue:

if there are reasons why the add object actuator is better I don’t know them, maybe something to do with threading or OOP.

but for my own games, I have seen no issue with scene.addObject