I’m trying to create a script, where upon clicking the mouse, a Rigid Body Joint is created between a cube and whatever other objects are around it. The cube, though, already has an existing RBJ upon entering the game - which is completely messed up when another is added with Python.
Here’s the script I have so far:
import bge cont = bge.logic.getCurrentController() own = cont.owner obj = bge.logic.getCurrentScene().objects hit = cont.sensors['Collision'] click = cont.sensors["Mouse"] if click.positive: for i in hit.hitObjectList: id1 = own.getPhysicsId() id2 = i.getPhysicsId() obj1['joint'] = bge.constraints.createConstraint(id1, id2,1,0,0,0) obj1['joint'].setParam(0, 0.0, 0.0) #No X translation obj1['joint'].setParam(1, 0.0, 0.0) #No Y translation obj1['joint'].setParam(2, 0.0, 0.0)
Upon running this script, all previous constraints start behaving very weirdly. They still work in a sense, but the RBJs become more of a weak force than an actual constraint - like an elastic spring or something.
Is this a common problem? It seems to work just fine in regular BGE…