Python Constraints

Hey,
I’ve been trying for a while to control my GUI-created generic constraints in the game engine but I couldn’t find any way to do it. I’ve tried the python constraints module using THIS doc but it doesn’t seem to create a generic joint/control it’s limitations.
Another question, Is it possible to control GUI constraints using python by their names?

Thanks in advance :).

but it doesn’t seem to create a generic joint/control it’s limitations

constraintType = 12 #6DOF constraint

Is it possible to control GUI constraints using python by their names?

No that is not possible at the moment.

But I have modified Moerdn’s patch and add a function to get the constraint ID form Blender.
https://projects.blender.org/tracker/index.php?func=detail&aid=31443&group_id=9&atid=127

But I don’t know how long it will take, until the developer integrate his patch into the trunk.

thanks (again) BluePrintRandom :stuck_out_tongue:

@HG1, I may check that out too.

EDIT: Is there a way of disabling the location/rotation limits completely? or disable the whole constraint temporarily?

Is there a way of disabling the location/rotation limits completely? or disable the whole constraint temporarily?

You can set the axis value to zero.

setParam(axis, min, max)

  • movement on the x, y and z axis.

  • Object 2 moves. But uses Object 1 axis to move on.

               <b>axis:  </b>
    
  • Type: integer

  • 0 = x axis

  • 1 = y axis

  • 2 = z axis

  • 3 = x axis rotation

  • 4 = y axis rotation

  • 5 = z axis rotation

    min:

  • minimum distance (0.0 is Object 2 object center)

max:

  • maximum distance (0.0 is Object 2 object center)

If you store the constraint id, you can remove the constraint completely with “bge.constraints.removeConstraint(id)”.

1 Like

I tried it but I can’t disable location limits, Is it possible to have rotation only like in the GUI?And also, If I store constraint’s ID, Can I reuse the same ID in separate scripts?

I tried it but I can't disable location limits,

Yes you need to set a value bigger then 0.0.

Is it possible to have rotation only like in the GUI?

Yes you need to set the rotation min and max value.

Can I reuse the same ID in separate scripts?

Yes you need to store the value into a global variable or a property. Look at the example

I made an example for you.
Constraint_6DOF.blend (92.1 KB)

1 Like