setDloc

Hi is it possible to use setDloc for a specific object. I.E.
motion = cont.getActuator(‘motion’)
objList = g.getCurrentScene().getObjectList()
last = objList[“OBlast”]
last.setDLoc(5,-5,0, 0)
g.addActiveActuator(motion,1)
This works for setLinearVelocity but doesn’t for this. I am using set Dloc as I don’t want my object affected by gravity and objects must have dynamic turned on for setLinearVelocity.
Thanks in advance.

its simpler than you might think, here a ready to use function


def applyDloc(object, dloc, local)
    if local:
        dloc = object.getAxisVect(dloc)
    p = object.position
    object.position = [p[0] + dloc[0], p[1] + dloc[1], p[2] + dloc[2]]

You’re very close. All you have to do is change your script to:


motion = cont.getActuator('motion')
motion.setDLoc(5,-5,0, 0)
g.addActiveActuator(motion,1)

This will set the “DLoc” for the object running the script. All you have to do is have the objects you are wanting to move around run this script. Now, if you are wanting to set the “DLoc” of an object from the script in a controller of a separate object, you’ll have to use global variables to save the controllers of the objects you’re wanting to affect so you can access their actuators in your script. You can check out accessing the actuators of other objects here: http://blenderartists.org/forum/showthread.php?t=151906

Nice That link sorted me out. Thanks

No problem…glad it helped.

Okay, sorry to be a pain but I can’t figure how to make Haidme’s script work I just get an error on the script which tries to get the object from DictObjects[].
The error says, Attribute error ‘module’ object has no attribute ‘DictObjects’.