collision impact strenght

Is it possible to get the impact strenght from a collision?

Well…you could figure something out by taking the linear velocities of the two colliding objects (or just the one, if it’s a ball on a wall or something). For example, I’ve used the speed of a thrown crate to determine how much damage it does on impact with an enemy. But no, there’s no built-in way to find out how hard a hit was.

Shows a .getReactionForce() method in the GameObject class. I doesn’t seem to work though. I’ve tried printing the value that function returns to the console just to see what the returned list looks like, but I’ve never seen anything but [0.0, 0.0 , 0.0]

Has anybody found a way to do this? It would be really handy to have an impact sensor.

What about getReactionForce()?
Look here.

getReactionForce always returns [0,0,0] regardless of situation… I think it’s sumo-only, left in for backwards compatibility like reinstancePhysicsBounds, both of which are functions I would LOVE to be able to use.

The best method I can think of for now would be to store the velocity in variables, then compare the current vel to last frame’s vel. The difference*mass is the total force applied. Unfortunately, that also includes any force you apply using logic or scripting.

I will add that function to the next blengine release =)

I need it for damage calculations, I guess using velocity changes is good enough solution if I ignore small changes.


Why doesn’t this script work? Effects of this script appear to depend on velocity instead of force.

cont= GameLogic.getCurrentController()
owner= cont.getOwner()

if owner.cInit:
    vel= owner.getLinearVelocity()
    vC= [vel[0]-owner.pVel[0],vel[1]-owner.pVel[1],vel[2]-owner.pVel[2]]
    d= vC[0]*vC[0]+vC[1]*vC[1]+vC[2]*vC[2]-5
    if d>0:    

owner.pVel= owner.getLinearVelocity()