You can go into math and vectors or you can use raycast.
If the black plane of your ground has a collider, then you can cast from the two top corners of your object downwards. If the raycast uses the rotation of the object it can be more accurate.
Then the hit point is the result. Convert that to local of the object and you’re done.
void Update(){
Vector3 left = GetPosition(topleft.position);
Vector3 right= GetPosition(topRight.position);
}
private Vector3 GetPosition(Vector3 position){
RaycastHit hit;
Vector3 result = Vector.zero;
if(Physics.Raycast(position, mainObject.transform.down, objectSideLength)){
Vector3 pos = hit.position;
result= mainObject.transform.InverseTransformPoint(pos);
}
return result;
}
This is more pseudo code than pure solution. But hopefully it will be a lead.
The falling part, I am not sure, I guess you want to check the result of the two vectors and do something about it.
if(left.y < value && right.y < value){ Fall(); }
Thanks for your reply but it show total error.