我想让我的玩家击中一个物体,销毁这个物体并触发一个动画,但是我尝试的所有东西都会导致错误。我在c#中比较新,所以答案可能很明显,但我需要帮助。我该如何设置它才能使对象消失并让玩家播放动画?这是我目前正在尝试的脚本。碰撞触发动画
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class succ : MonoBehaviour
{
public float speed = .15f;
public static float jumpSpeed = 170f;
void Start()
{
GetComponent<ConstantForce2D>().enabled = false;
GameObject.Find("goal");
}
public bool animation_bool;
private object coll;
private object other;
void Update()
{
OnCollisionStay2D(Collision2D coll);
{
if (coll.gameObject.tag == "succ") ;
{
animation_bool = true;
GetComponent<Animator>().SetBool("succ", animation_bool);
GetComponent<ConstantForce2D>().enabled = true;
Destroy(other.object);
}
}
}
private void Destroy(object gameObject)
{
throw new NotImplementedException();
}
private void OnCollisionStay2D(Collision2D collision2D, object coll)
{
throw new NotImplementedException();
}
}
在'Update'函数内部看到'OnCollisionStay2D'回调函数后,我建议你先学习C#。那里有很多在线教程。这将节省您的时间,同时,节省其他人的时间来阅读您的问题。 – Programmer