force of collison

Jun 12, 2009 at 10:14 PM
Edited Jun 12, 2009 at 10:16 PM

i have already posted about this in the past and got help about using this code the problem is if i drop the same distance the value is diffent
, and somtimes if i drop futher it dos no more damage than a lesser drop.
also sometimes when falling on to a box the value goes negative and keeps getting better.

is this normal for this way of solving this problem?

public bool PlayerColEvent(Geom geom1, Geom geom2, ContactList list) ~
float maxDamage = (128 / 2f) * -1;
float maxPenetration = 0;
//The first contact is always the deepest (most penetration)
if (list.Count > 0)
maxPenetration = list[0].Separation; //Damage to apply, ranging from 0 to 1 damage = maxPenetration / maxDamage;

return true;

Jun 12, 2009 at 11:01 PM

It is one way of doing it. You can also simply get the velocity at the points of contact.


private bool OnCollision(Geom geomA, Geom geomB, ContactList list)
    Vector2 position = list[0].Position;
    Vector2 vel;
    geomA.Body.GetVelocityAtWorldPoint(ref position, out vel);
    return true;
That will get you the velocity at the deepest point of contact. You might want to change it to suit your needs.