Using python to change a 6dof constrain target

How can I change the target of the 6dof on the fly?

I can’t find the code source like obj.rigidTarget or whatever

I used the empty parent method, but I am still curious,

Not sure what you mean with empty parent method but if you refer to Rigid body joints than the only way to access them is if you create them at runtime and store the joint in a property for later use. Be sure to clear out the property if you remove the joint else BGE will crash.

So here is part of the code I used in the BRIK add-on to create 6DOF rigid body joints

constraint_type = 12 #6DoF joint
flag = 128 #No collision with joined object.
joint = bge.constraints.createConstraint(object_id, target_id, constraint_type, piv_x, piv_y, piv_z, piv_Rx, piv_Ry, piv_Rz, flag)
joint.setParam(0, float( settings.get("x_min", 0.0) ), float( settings.get("x_max", 0.0) ) )
joint.setParam(1, float( settings.get("y_min", 0.0) ), float( settings.get("y_max", 0.0) ) )
joint.setParam(2, float( settings.get("z_min", 0.0) ), float( settings.get("z_max", 0.0) ) )
#Parameters 3 = limit x rotation, 4 = limit y rotation, 5 = limit z rotation
if settings.get("Rx_min", None):
    joint.setParam(3, float( settings.get("Rx_min", 0.0) ), float( settings.get("Rx_max", 0.0) ) )
if settings.get("Ry_min", None):
    joint.setParam(4, float( settings.get("Ry_min", 0.0) ), float( settings.get("Ry_max", 0.0) ) )
if settings.get("Rz_min", None):
    joint.setParam(5, float( settings.get("Rz_min", 0.0) ), float( settings.get("Rz_max", 0.0) ) )

where “settings” refers to a dictionary where I stored all the joint settings. If you store the joint like

object["constraint"] = joint

you can use this property to change the 6DOF limits later.

You can even get joint rotation/translation with joint.getParam(parameter index). (This is not documented in the API :evilgrin:)

this bug (veeery annoyng) not there more!
some good man have fixed it , about in 2.62 or 2.63.

you can add and forget constraints as any other object

only not forget any argument, put all 10 (ob1,ob2,12,0,0,0, 0,0,0, 128) , otherwise give crash again.
this is the only issue that i know .
all other work perfectly now ! :wink:

hrm… can you put this into a actuator? a sensor?

sensor - act based on offset/angle, and actuator change target location of 6dof object and offset, and limits with a logic stack?

this would make robotics much easier, as I could have an area that I want to be in, and have it apply forces based on is location until it hits the location…

that would be a neat pulldown for the 6dof actuator, like in edit actuator…

ok, i put just some example ,(not that i know it very well)
but there 4 kind of constraints for every axis to setup, so,a undefined number of “combinations”

there a tutorial on tutorialsForBlender3D , well done that explain all kind of constraints.


RBJ.blend (79.6 KB)

ops , i replaced my old post … bump

have you see as is easy ? :smiley:
in THIS case , must say , python is not much magic

marcoIT want to join the team? we need a full-time python coder, I am coding python now, and logic, but I am still very new to python, at this point there is only me and a very talented modeler,

I need to get this project locked down, get some add revenue, and feed family etc, as well as donate to improve the bge

@ this point I am doing story, concept design and implantation in logic and python, rough modeling and game layout/engineering, storyboarding and component interaction design,

what game? i not see a plan
i counsill to make a FPS that is easy (is that i want make since other kind here too complex)
this is doable

I am already well on my way…

check out my updates

I pick up “component” I look at another “Component” I target the side of the “component”

I stick the components together,

now imagine the first component is a motor, the second a wheel, I attach a third in the right location that is a battery and we have a system running