每当它在云层上弹跳时,我都试图播放Blob中的动画

时间:2019-01-27 17:20:32

标签: unity3d animation

我希望它每次在云层上反弹(此脚本所附加的内容)时,都会从blob游戏对象中播放动画。

我不知道该怎么办。

public class PlatForm : MonoBehaviour
{
GameObject Player = GameObject.FindWithTag("Player");
Animator m_Animator;
public int Score;
public float jumpForce = 10f;
public GameObject Particals;
void Start()
{


}
void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.tag =="Player")
    {
        if (collision.relativeVelocity.y <= 0f)
        {
            Rigidbody2D rb = collision.collider.GetComponent<Rigidbody2D> 
   ();
            if (rb != null)
            {

                Vector2 velocity = rb.velocity;
                velocity.y = jumpForce;
                rb.velocity = velocity;
                Instantiate(Particals, transform.position, 
                                               transform.rotation);
                Destroy(gameObject);

                PlayerPrefs.SetInt("Score", PlayerPrefs.GetInt("Score") + 
1);

                Player.GetComponent<Animator>().Play("Blob");
            }
        }
    }
}

 }

0 个答案:

没有答案