我希望它每次在云层上反弹(此脚本所附加的内容)时,都会从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");
}
}
}
}
}