/// <summary>
/// This is a smash/splash/squash test to kill character if needed
/// </summary>
void OnCollisionStay2D(Collision2D collisionInfo)
{
//if (collisionInfo.collider.gameObject.layer == Configuration.instance.staticGeometryMask) {
if (collisionMask.Contains(collisionInfo.collider.gameObject.layer))
{
Vector3 max = colBounds.max;
Vector3 min = colBounds.min;
Debug.Log("OnCollisionStay!!" + collisionInfo.collider.gameObject.GetFullName());
foreach (ContactPoint2D contact in collisionInfo.contacts)
{
//Debug.DrawRay(contact.point, contact.normal, Color.blue);
((Vector3)contact.point).Draw();
if (contact.point.x - min.x < max.x - contact.point.x)
{
min.x = contact.point.x;
}
else
{
max.x = contact.point.x;
}
if (contact.point.y - min.y < max.y - contact.point.y)
{
min.y = contact.point.y;
}
else
{
max.y = contact.point.y;
}
}
colBounds.SetMinMax(min, max);
colBounds.Draw(transform, Color.blue);
if (bounds.size.x * bounds.size.y * 0.8 > colBounds.size.x * colBounds.size.y)
{
Debug.Log("Character crushed!!!");
health.Kill();
}
}
}