Collision Objects, JavaScript

I would like to know how i can access the object i am colliding with to figure out how my object should react.(trying to make AI) for instance if it hits a player i want it to start attacking but if it hits a wall it will just turn in another direction.

Put this in your AI script:

function OnTriggerEnter (other : Collider) {
    if (other.gameObject.CompareTag ("Player")) {
        //start attacking
    }
}

If you’re not using a trigger, it’ll be something like:

function OnCollisionEnter (collision : Collision) {
    if(collision.Collider.gameObject.CompareTag("Player")){
        //start attacking
    }
}