Answers for "what force did collider collide with?"
http://answers.unity.com/questions/200633/what-force-did-collider-collide-with.html
The latest answers for the question "what force did collider collide with?"Answer by TheGameLearner
http://answers.unity.com/answers/1514042/view.html
use collision.impulse
you can get Vector3 value of force.
OnCollisionEnter(Collision col)
{
Vector3 impactForce = col.impulse / Time.deltaTime;
//Handle ahead yourself!! Cheers
}Mon, 04 Jun 2018 05:18:21 GMTTheGameLearnerAnswer by Peter G
http://answers.unity.com/answers/200699/view.html
I'm not sure how you would isolate force strictly from collision information, but you could calculate the impulse on the object relatively easily.
Impulse = m∆v
Assuming we have an inelastic collision.
m1v1 + m2v2 = (m1 + m2)vf
vf (velocity final) = (v1m1 + v2m2) / (m1 + m2)
then....
∆v = vf - v1
so the impulse = m∆v
Now, collision information provides a relative velocity. If you set the velocity of the second object to the relative velocity and then treat the velocity of your current object as zero, you can simplify the math.
v1 = 0.0
v2 = collision.relativeVelocity
vf = v2m2 / (m1 + m2)
∆v = vf
In code terms:
function OnCollisionEnter (col : Collision) {
var vFinal = col.rigidbody.mass * col.relativeVelocity / (rigidbody.mass + col.rigidbody.mass);
var impulse = vFinal * rigidbody.mass;
}
Now, elastic collisions. If there is no energy loss (bounciness >= 1) then the ∆v is the velocity of the 2nd object minus the velocity of the first object:
var impulse = rigidbody.mass * ( col.rigidbody.velocity - rigid.body.velocity);Sun, 01 Jan 2012 04:23:57 GMTPeter GAnswer by aldonaletto
http://answers.unity.com/answers/200676/view.html
You can't know the reaction force directly, but it can be calculated: you can get the rigidbody.velocity variation due to the collision, calculate the acceleration and multiply by the rigidbody.mass to get the force. Unfortunately, the velocity changes in the first FixedUpdate *after* the collision. A good way to work around t$$anonymous$$s is to create a fake OnCollisionEnter - let's call it OnAfterCollision - and call it in the first FixedUpdate after the collision:
private var fCollided: boolean = false;
private var fLastVel: Vector3;
private var fCollision: Collision;
function OnCollisionEnter(coll: Collision){
fCollision = coll; // save collision data
fCollided = true; // signal that a collision happened
}
function FixedUpdate(){
if (fCollided){ // if collision happened...
fCollided = false; // reset flag
// calculate acceleration due to collision
var acc = (rigidbody.velocity - fLastVel)/Time.fixedDeltaTime;
// convert to force:
var force = rigidbody.mass * acc;
// call OnAfterCollision passing the Collision
// info and the reaction force:
OnAfterCollision(fCollision, force);
}
fLastVel = rigidbody.velocity; // update last velocity
}
// place your damage code in OnAfterCollision: you will have all the
// original Collision data and the reaction force:
function OnAfterCollision(coll: Collision, force: Vector3){
print("Force="+force.magnitude);
}Sun, 01 Jan 2012 02:09:26 GMTaldonalettoAnswer by suyujin
http://answers.unity.com/answers/200661/view.html
To my understanding you can't actually access collision force, per se. You'll probably want to look at collision normals, the velocity, and object masses. I'm sure you can find an equation pretty quickly. There was a pretty long forum discussion on the matter here: http://forum.unity3d.com/threads/23746-getting-impact-FORCE-not-just-velocity Might help you out a bit! Good luck!Sun, 01 Jan 2012 00:10:23 GMTsuyujin