Need Help To activate animation (mecanim) with collider.

Hello, i´m really n00b with scripting i know the basic things about C#, i´m making a Game about Parkour, i want to do a movement when the player throughs a collider, By example: In the scene there is a cube, that the player would dodge, around the cube exist a collider and the collider would activate the animation of the player.

I hope you can help me. Or you can show me some tutorials about it.
PD: Sorry for my bad english. =)

Hi

I hope i can help you.

We go to forget other elements in the scene for the explanation, we go to consider only the cube element and character element in the scene. I suppose that you put properly the tags on elements in scene (for example, in character, the tag is character, really not necessary, but is a good practice)

If you want to detect the collision between two elements, one of them have to have a rigibody component, i suppose that if you are doing a parkour game, all your elements have a rigibody component for phisics effects and collision.

For detect the collision, you con use two sentences: OnCollisionEnter or OnTriggerEnter, there are some differences between both, but for resume, the OnTriggerEnter is using for detect the collision between colliders without necessary that there is a body element, for example, a collider for detect when the enemys have to be destroyed.

In box´s script you have to write like this:

public void OnTriggerEnter(Collider object_collider){
               /// the tag of the character will be Character
        if (object_collider.tag == "Character") {
             /// we want to get the animator of the character
                         Animator Character_Animator = object_collider.gameObject.GetComponent<Animator>();
                       /// we already have the animator, if you want to play, for example, a trigger called "Jump", only have to put:
                      Character_Animator.SetTrigger("Jump");
        }
}

There are some forms to do this, for exemple, instead of the box detect the collision with the character, the character is the object who detects the collision with the box

I hope this attend to you

Oh right man, i will study the theme. Thank you.