Like the addObject() function, I’m looking for a way to add groups. I have to objects grouped together on a different layer. These have a Rigid Body Joint Constraint applied to them and addObject() function does not (seem to) let me keep this constraint.
Maybe there is another way of achieving this? I could not find an addObject() function although I’m not great at navigating the bge api.
Thanks for any help.
EDIT
As Monster has pointed out there is no groups in the bge, however as he also points out I can spawn an object and use Python to set up the rigid body joints. After a bit of trial and error I was able to get the settings more or less how I like them.
This webpage was helpfull. The creator includes an example blend to experiment with.
The example above is with the constraint type 12, but it also works with constraint type 2. Axis rotation is described with radians (something I had to find out about).
There are no groups in the bge. You can add instantiating objects (objects with doupligroup enabled). As far as I remember rigid body joints need to be set up via Python as the are not established on instances. This might have been changed.
That example seems pretty fully fleshed out, yeah, but there’s no reason to use the magic number 2 for the constraint_type variable. You should be able to use the constraints.LINEHINGE_CONSTRAINT constant.
constraint.setParam(0, 0.0, 0.0) #Limit the location in X axis
constraint.setParam(1, 0.0, 0.0) #Limit the location in Y axis
constraint.setParam(2, 0.0, 0.0) #Limit the location in Z axis
constraint.setParam(3, 0.0, 0.0) #Limit the rotation in X axis
constraint.setParam(4, 0.0, 0.0]) #Limit the rotation in Y axis
constraint.setParam(5, 0.0, 0.0) #Limit the rotation in Z axis
0.01 is a very low value, try increase it. Also, you want to limit the rotation or the movement? with that code you are limiting the movement in the local axis X a value of 0.01 and what type of constraint are you using? hinge?
The constraint_type 12 is a rotating motor as far as I’m aware. The setParam(9,1.5,15.0) would set the axis to x the speed to 1.5 and acceleration to 15.0…
What happen in my blend? Other objects dissapear. Press p and then remove firts python script and press p again.When I create constraints all objects in scene except 1 disappear. I don’t understand nothing… Attach file