collision forces

Hi,

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
  1. 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…

Attachments

force1.blend (168 KB)

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.

Is it all zeros past the decimal or is there an actual number several places past it?

I think the values returned may be quite small, try making it an object float property and multiply it by 10,000 or something.

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.

multiplicating the applied impulse didn’t help :frowning:
I tried to play around with the mass and other parameters - but nothing works

Does anybody have a .blend file with a workink script for the applied impulse?
Only to have a look on it.

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.

Attachments

Collision_velocity_change.blend (139 KB)