cube로 죽은 후에 리스폰하는 걸 만들어봤다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TestRespawn : MonoBehaviour
{
[SerializeField] private Button btnSuicide;
[SerializeField] private GameObject playerGo;
[SerializeField] private Slider slider;
private bool onRespawn = false;
// Start is called before the first frame update
void Start()
{
this.btnSuicide.onClick.AddListener(() => {
this.StartCoroutine(this.CoRespawn());
});
}
private void Update()
{
if(onRespawn)
{
this.slider.value += Time.deltaTime;
}
}
private IEnumerator CoRespawn()
{
this.onRespawn = true;
Debug.Log("되는중");
this.playerGo.SetActive(false);
yield return new WaitForSeconds(3f);
Debug.Log("생성");
this.playerGo.SetActive(true);
this.onRespawn = false;
}
}
'Giant vs Human 팀프로젝트 개발일지' 카테고리의 다른 글
[Giant vs Human 팀프로젝트/ Photon] 지연 보상 (1) | 2023.12.06 |
---|---|
[Giant vs Human 팀프로젝트] Photon 멀티 동기화 (1) | 2023.11.30 |
[Giant vs Human 팀프로젝트, Mobile] 대포가 주변에 있으면 대포발사 버튼이 활성화되고 버튼을 누르면 포탄이 발사 (0) | 2023.11.29 |
[Giant vs Human 팀프로젝트, Mobile] 조이스틱을 통한 이동, 버튼을 누르면 공격 (0) | 2023.11.29 |
[Giant vs Human 팀프로젝트, Meta Quest, VR, Oculus] UI 작업 - 게임시작 시 Start버튼 따라다니기, 남은 거리 보여주기 및 남은 시간 보여주기 (0) | 2023.11.29 |