check for intersection on update?

Hi, i’d like to check if a GameObject is within the boundaries of another game object. I know there are physics functions but they don’t tick every frame so sometimes, my gameObject moves through obstacles even if it should be destroyed as soon as it “hits” another object.

Is there a way to really check if something “collides”? I’m not using physics but moving my object manually. I just want to check if I’m hitting a wall (built from 1x1x1 cubes with scripts attached).
I also tried doing a raycast but it also works only like 10% of the times and most of the times my object tomes through the obstacle :confused:

Firstly, make sure the object has a collider. In the scene view, click on the object and press Physics > Collider (BoxCollider, MeshCollider, depending on the shape), like so:
alt text

Then, assign a script to the object and use the OnCollisionEnter method.

Example:

Javascript example:

function OnCollisionEnter(collision : Collision) {
    // Debug-draw all contact points and normals
    for (var contact : ContactPoint in collision.contacts) {
        Debug.DrawRay(contact.point, contact.normal, Color.white);
    }

    //Collision detected!
}