如何在播放器的本地位置播放动画

时间:2018-07-25 16:50:49

标签: c# unity3d animation

正是标题所要求的。这是我现在拥有的动画代码。我需要这样做,以便在播放动画时,游戏对象不会立即捕捉到原点,然后执行操作。有任何想法吗?

void OnCollisionEnter2D (Collision2D collision) {

    //Checks whether the object has collided with a rock
    if (collision.gameObject.name == "TopRock1" || collision.gameObject.name == "BottomRock1")  {
        Animation anim = GetComponent<Animation> ();
        anim.Play ("playerCollision");

        if (anim.IsPlaying ("playerCollision") == false) {
            Destroy(gameObject);
        }
    }  
}       

0 个答案:

没有答案