대포 근처에 도달하게되면 공격버튼이 활성화된다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TestTowerAround : MonoBehaviour
{
[SerializeField] private Transform towerTr;
[SerializeField] private Button btnTowerAttack;
[SerializeField] private Transform bulletTr;
[SerializeField] private GameObject bulletGo;
private void Start()
{
this.btnTowerAttack.onClick.AddListener(() => {
GameObject go = Instantiate(this.bulletGo);
go.transform.position = this.bulletTr.position;
go.transform.rotation = this.bulletTr.rotation;
});
}
// Update is called once per frame
void Update()
{
float dis = Vector3.Distance(this.transform.position, this.towerTr.position);
Debug.Log(dis);
if(dis <= 0.4f)
{
this.btnTowerAttack.gameObject.SetActive(true);
}
else
{
this.btnTowerAttack.gameObject.SetActive(false);
}
}
}
'Giant vs Human 팀프로젝트 개발일지' 카테고리의 다른 글
[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 |
[Giant vs Human 팀프로젝트, Meta Quest, VR, Oculus] 프로토타입 MapScene (0) | 2023.11.29 |