Alternative for Physics.ComputePenetration ?

Hi. I’m trying to learn if the cube has entered into sphere using the script attached to the plane.

I tried using Physics.ComputePenetration but it is a little bit slow. Is there an alternative or a way to use OnTriggerEnter in the script that attached to the plane ?

1 Like

There are a couple of things you need for this to work the standard Unity way:

The object that can freely move (the cube) needs
a. RigidBody,
b. Collider

The object that can be entered (the sphere) needs
a. Collider with isTrigger set to True,
b. a custom script

The custom script needs to have a method void OnTriggerEnter(Collider coll){}:

void OnTriggerEnter(Collider coll){
   //your code
   Debug.log("The object that entered "+gameObject.name+" is "+coll.gameObject.name);
   //your code
}

Did you find another solution? Becuase i also see it is slow a little bit.