Click to animate object not working

I have imported a max file into Unity which contains two simple boxes. These boxes both have animations which simply rotate them individually 90 degrees. In Unity I am trying to get to a situation where I can click on Box01 and Box01's animation plays and similarly when I click on Box02 Box02's animation plays. If I put a collider over the group it allows me to click and run either animation but that only gives me on clickable item. If I apply a collider to both boxes and attach a script to each box it runs the correct scripts but does not display the animations.

The two boxes are called Box01 and Box02 with their animations being called bx01 and bx02. The following two scripts are linked to each box which when clicked does indeed print out the relevant messages but does not animate. No error messages are displayed.

function OnMouseDown () { animation.Play("bx01"); print("Played 01"); }

function OnMouseDown () { animation.Play("bx02"); print("Played 02"); }

I have been searching for the answer for this for days and cannot work it out. Can anybody shed some light on this problem??

Did you import the whole scene (with both boxes in it) from max? So both of them are child of the same GameObject? Then the problem is probably that the Animation component is attached to the parent object. The boxes probably don't have animation components themselves, or they don't have animations attached.

A better approach would be to import a single box, with animations, then use that box as a prefab with the "rotate on click" script attached to it.