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.
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
con = logic.getCurrentController()
obj = con.owner
addPObjectA = con.actuators['Add_PObjectA']
col = con.sensors['PObjectBCol']
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)
if obj['rubbishCount'] == obj['rubbishTotal']:
elif obj['rubbishCount'] < obj['rubbishTotal']:
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 just looks tidier and i would rather not use so many logic bricks and noodles