个人项目(6):其他
胜利
我们要为游戏添加胜利条件,即在终点处放置一个立方体的触发器,将其设置为不可见,当主角进入到触发器中则显示游戏胜利UI并使场景中所有其他角色暂停行动。
public class endgame : MonoBehaviour
{
public playeraction player;
bool isend=false;
Transform follow;
void Start()
{
follow=GameObject.FindWithTag("Player").transform;
}
private void OnTriggerStay(Collider other){
if(other.transform==follow){
isend=true;
}
}
private void OnTriggerExit(Collider other){
if(other.transform==follow){
isend=false;
}
}
void Update()
{
if(isend==true){
player.iswin=true;
}
}
}
if(iswin==true){//角色胜利
Animator