Add multiple objects with one actutor

In my game, I have a crash sequence set up so it will add debris pieces.
HOW can I add multiple objects at once with one actuator?

-Thanks

Give it a try and find out.

haha… I know how. but should I tell you?
lol

use act.instantAddObject() once for each new object you wish to create. If you are creating different objects then you need to change the target object that the actuator will be creating before each use of instantAddObject()

aint it a bitch when Social gets to you first?

I have very little python expirience, and i would be greatful if you would explain the act.instantAdObject() script more.

I think you mixed up your functions here. There is no “instantAddObject” function for the Add Object actuator.

http://www.blender.org/documentation/pydoc_gameengine/PyDoc-Gameengine-2.34/KX_SCA_AddObjectActuator.KX_SCA_AddObjectActuator-class.html

Self-Adhesive>

Follow what spike said, but instead of the non-existing function he has listed there, use act.setObject(“Name”).

For a quick intro to BGE Python, you may want to look at my recent tutorial on the subject: http://blenderartists.org/forum/showthread.php?t=80826

It damn well better be.

thats why social got so many f-ing post lol.

The instantAddObject() function isn’t covered in the documentation. If you search for the 2.42 physics demos, there’s a file called addObject2.blend that uses it. I’m not 100% sure how it works though. It basically creates a set number of rows and columns of an object

I had a small debris explosion and used one add object actuator. On another layer I made an empty, named Burst. Then I made a bunch of ALT-D copies of it and parented them to the original. Each copy had it’s own add object actuator that added differnet debris.

When the enemies die, they addObject: Burst, and it adds the empty and all the children empties. The empties then add all their little bits of debris.

actually there is a .instantAddObject() like skullbunny said it’s not in the docs.

and how to use it is have the actuator in python and be like


cont = GameLogic.getCurrentController()
own = cont.getOwner()

act = cont.getActuator("addObject")
#where addObject is the add object actuator

act.instantAddObject()
#as soon as you use this it adds the object
# you dont need to use GameLogic.addActuiveActuator(act,1)

because the addActiveActuator() dont add the object till the next frame so you can add more than one object.

but you could use


cont = GameLogic.getCurrentController()
own = cont.getOwner()

act = cont.getActuator("addObject")

act.instantAddObject()
act.instantAddObject()
act.instantAddObject()
act.instantAddObject()

and that would add four objects

or you could even use


act.setObject("debris01")
 act.instantAddObject()
act.setObject("debris02")
 act.instantAddObject()
act.setObject("debris03")
 act.instantAddObject()
act.setObject("debris04")
 act.instantAddObject()
 

to add 4 diffrent objects with the same actuator at one virtually one time

Ahhh, I see. Thanks scaboots and skullbunny. (my mistake spike)

My confusion is based on the fact that even “print dir(act)” doesn’t bring that function up as an option, and as we all know it’s not in the docs. (why is that btw?)

Is there a place where all these “undocumented” functions are listed. (I guess they wouldn’t be undocumented then, but still)

I’d like to keep up to date with the API.

As a far as I could tell, the undocumented parts are the recent additions: .instantAddObject(), the PhysicsConstraint module, and the GLSL functions. Physics and GLSL have some partial documentation on the Wiki and on Snailrose’s site, but not in the actual development pydocs. I assume that Erwin and the rest are focused on programming and don’t have time to expand the pydocs.

I was asking some questions a while back on the GE Developers Forum and was told there’s no Game Engine Python guru, so I think that’s part of the problem. I was working on a site to try and bring all the info into one place, but got side tracked with actual work. Hope to get back to it sometime this winter.

Social:It shows up for me with “print dir(act)”:
[‘getLastCreatedObject’, ‘getLinearVelocity’, ‘getObject’, ‘getTime’, ‘instantAddObject’, ‘setLinearVelocity’, ‘setObject’, ‘setTime’]

Considering that documentation Social linked to is for blender 2.34, there might be quite a few changes in the new version of blender. I wish someone would make a new version of the docs with calls for 2.42.

Thanks everyone, Ill go try this.

scabootssca, I can add 4 of the same objects at once, but if i use

act.setObject(“so and so”)
act.instantAddObject()

to work. It says the error is in the act.instantAddObject() syntax, but that works fine until I start to add different specific object names.

well it works for me here’s a .blend

http://www.box.net/public/22g2mgc1jb

Thanks, it works now