Anyone know how to calculate area that touch by two collision?

Two gameObject collide together,
and i wanna calculate area of touching between two collision,
any idea?

Example image
I wanna calculate the green line area.
and i wanna calculate if area touching less then 50%,
the red box will destroy.

1387567--71112--$Untitled-2.png

No one can help for it?

You can use a raycast to check info about the normal so you can see how close to the edge you are, or you can use the cast to check the distance between the two objects center transform.position.

What you trying to make ?

I’m trying make a games just like tower bloxx,
wanna know how to calculate if the collision between 2 objects is less than 50 %

This is the second post you’ve made on this exact question…

You are providing a bit too little information for us to help you.
What kind of physics model are you using? How are the objects allowed to move? Are the objects allowed to rotate, we cannot guess.

If they can’t rotate and the boxes are the same size, you can just test distance between centers in x and compare that with half the width.

i using a cube that fall down to the plane, the object not allowed to rotate,
the box will the same size,
how to test the distance between centers in x and compare that with half the width?
I really a newbie on this thing,
very thanks for your help.

I would think the first step would be to reference the object its colliding with by assigning it to a var on collision. I’m not familiar with the game type your shooting for, so if you need at some point to check for side or bottom blocks you may want to put all the blocks that are colliding with your block in an array. Ofc if your only needing the top block one var should do the trick.

Place the script below on each block and tag them Block. Hope this helps a little. :wink:

var block : Transform;

///===============================================================///
function OnCollisionEnter ( col : Collision ) {
    //------------//
    if(col.collider.tag=="Block") {
      //------------//
      block = col.collider.transform;
      //------------//
    }
    //------------//
    if(block) {
      //------------//
      print("("+name+") - blocks array = ("+block+")");
      //------------//
      var d = Vector3.Distance(block.position, transform.position);
      //------------//
      Debug.Log("("+name+") - Distance = ("+d / 2+")");
      //------------//
      block = null; /// CleanUp
      //------------//
    }
    //------------//
}
///===============================================================///

Thanks so much,
by the way i also created my solution by myself,
anyway, thanks so much :slight_smile:

By the way,
how you write in C#?