Advertisement

sabge - springs based mechanics (porting and extending bge|upbge API)

sabge - springs based mechanics (porting and extending bge|upbge API) this is useful for car suspensions, or ,for example, characters jumps
it's done using the setParent function with JOINT_PRISMATIC mode:
cubeObj.setParent(playerObj, jointType=1, jointAxis=[0,0,1], ...)
the logic for the spring is:
if self.inputs.getKeyState("RMB")==1:#right mouse button justPressed
cubeObj.jointController.set_targetPosition(pos=-1.5, force=5000)
if self.inputs.getKeyState("RMB")==3:#right mouse button justReleased
cubeObj.jointController.set_targetPosition(pos=0, force=400)

bge/upbge

Post a Comment

0 Comments