[Bf-committers] A patch to add an addObject() method to KX_Scene

Mitchell Stokes mitchell at daboys4u.com
Sun Feb 22 04:37:52 CET 2009


I've created a patch to add an addObject() method to KX_Scene so that
I could avoid using the add object actuator.

Here's the link to the tracker entry:
http://projects.blender.org/tracker/index.php?func=detail&aid=18309&group_id=9&atid=306

The following is the description that's in the tracker:

I got tired of using the Add Object Actuator, so I added an
addObject() method to KX_Scene. Here is it's PyDoc entry:

def addObject(object, other, time=0)
	"""
	Adds an object to the scene like the Add Object Actuator would.
		
	@param object: The object to add
	@type object: L{KX_GameObject} or string
	@param other: The object's center to use when adding the object
	@type other: L{KX_GameObject} or string
	@param time: How long (in seconds) that the new object will live
	@type time: int
	"""

An example:

gl = GameLogic
own = gl.getCurrentController().getOwner()
scene = gl.getCurrentScene()

ob = scene.addObject("Cube", own)

print ob.name


More information about the Bf-committers mailing list