Animation OnTrigger

Hi, i only can make easy animation in Unity, but how to make animation that start when i touch cube? For example i have 2 cubes. First cube is static and when i touch first cube, second cube will be animated. Second cube animation is disabled and not working when start level. How to make script in c#? I tried, but animation is playing when i start level- i dont want this.

I’m a noob so sorry if I’m wrong, just trying to help.

Try this, Open the Animation tap and create two clips. Call one Idle and the other Animation1 (or whatever you want) (See Image A)
in the Idle clip just put one image on the time line. This will create a motionless animation. On the other clip put your animation in the time line. Now Open the Animator tap. Find the Idle Square and right click it. In the drop down select “Set as layer default state” Right click it again and click “Make Transition” Drag the arrow to the Animation1 square. Do the same to animation1 and drag the arrow back to idle. Find the Parameters tab in the Animator(See “image B”). Click the plus to add an new bool and call it “playAnimation1” or whatever makes sense to you. Now click on the arrow pointing to Animation1 and in the Inspector find Conditions.(See Image C) Add one if needed. The left box is the variable type and the right is the value. Set it to playAnimation1 = true. Do the same for the arrow pointing back to idle. Change conditions to playAnimation1 = false. Now to change the animations in code.

Store the animator like this

private  Animator myAnimator;

then to change the animation clip like this.

MyAnimator.SetBool (“playAnimaiton1”,true);