I want to get the force/impulse on a cube, when it is hit by a cone.
After trying it with getReactionForce() and getting only a 0.0. I noticed it is not implemented for bulletphysics. So I tried to get the impulse via getAppliedImpulse()
But i always only get a 0.0.
This is my Python-Script1 (always executed):
# get object list
objList = GameLogic.getCurrentScene().objects
# get objects
objCube = objList["OBCube"]
objCone = objList["OBCone"]
# use a 6DOF constraint
constraintType = 12
# get physis IDs
objCube_ID = objCube.getPhysicsId()
cube_6DOF = PhysicsConstraints.createConstraint( objCube_ID, 0,constraintType)
# get the constraint ID
objCubeConstraint_ID = cube_6DOF.getConstraintId()
# save the constraint ID as a objCar variable
objCube["constraint_ID"] = objCubeConstraint_ID
Script (executed on collision)
import GameLogic
import PhysicsConstraints
# get object list
objList = GameLogic.getCurrentScene().objects
# get objects
objCube = objList["OBCube"]
objCone = objList["OBCone"]
objCubeConstraint_ID = objCube["constraint_ID"]
# get the applied impulse
appliedImpulse = PhysicsConstraints.getAppliedImpulse(objCubeConstraint_ID)
print appliedImpulse
Can anybody help me?
There must be something wron in general…
I am looking for the same feature for my swordfighting game in the work in progress forum to make the volume of collision sounds proportional to the collision. Unfortunatly I can’t get it to work either, getting back zeros as applied impulse.
It gives 0.0 as output. I think it is already a float and I multiplied it with 1000000000.0 and that didn’t do anything. I did notice that the cube mass was 0.1 but I varied both up to 500 and no result.
EDIT: I find it odd though that it gives back a number, I would expect a vector or something.
On a suggestion of Social I tried a different approach. I monitor the change in the objects velocity which is easy to relate to collisions, just include the objects mass. It takes all the object collisions together though. A slightly more complex script that monitors the relative velocities between the objects would also work.
Rotation and torque might be a bit more tricky…, as you would want the position of the impact as well.