In blender 2.5, I’m trying to change actuator parameters at runtime via python and I’m having some trouble.
import bge
import random
cont = bge.logic.getCurrentController()
obj = cont.owner
#generate a random offset
offset = random.random() * 3.0
#for all actuators
for act in cont.actuators:
print(act)
print("before", act.linearVelocity) #print before
print("offset", offset)
act.linearVelocity[0] = act.linearVelocity[0] + offset #add offset
# ^^^ doesn't work. why?
print(act.linearVelocity)
print('after ', act.linearVelocity) #print after
cont.activate(act) #activate actuator
It doesn’t seem like AddObjectActuator’s linearVelocity is read-only, and for 2.49 there is a setter for it so i think it’s meant to change at runtime… And yet it doesn’t work. I’ve included a .blend for context. Any suggestions? I have all of 6 hours worth of experience with python, so it might be something very basic that’I’m doing wrong…
Attachments
rigid_physics_test2.blend (703 KB)