Search Unity

Animating on Trigger

Discussion in 'Animation' started by ZakWoolley1, Jan 26, 2015.

  1. ZakWoolley1

    ZakWoolley1

    Joined:
    May 28, 2014
    Posts:
    10
    I have a block that I want to animate when the player touches it. I've made a slightly bigger box collider around the one that give it a physical property and have set that to a trigger. Here's my code

    function OnTriggerEnter2D(Other : Collider2D){
    if(Other.gameObject.tag == "Player"){
    audio.Play();
    animation.Play(); }
    else {
    audio.Stop(); } }

    The audio is playing perfectly so the if statement is working. Can any one tell me what's wrong with my code?