그래서 머리가 움직여도 계속 얼굴 앞을 따라다니게 만들어준다.
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class TestCountDownDistance : MonoBehaviour
{
[SerializeField] private Transform giantTr; //거인 위치
[SerializeField] private Transform endTr; // 목적지
[SerializeField] private TMP_Text countDownTxt; //남은시간
[SerializeField] private TMP_Text distanceTxt; //남은거리
[SerializeField] private GameObject startGo; //시간시작
private float timer = 60f;
private float distance = 0f;
private float truncatedTimer;
private float truncatedDistance;
// Update is called once per frame
void Update()
{
this.distance = this.endTr.position.x - this.giantTr.position.x;
if (this.startGo.activeSelf == false)
{
this.timeAttack();
this.goalDistance();
}
}
private void timeAttack()
{
this.timer -= Time.deltaTime;
this.truncatedTimer = Mathf.Floor(this.timer * 100f) / 100f;
this.countDownTxt.text = this.truncatedTimer + "s";
}
private void goalDistance()
{
this.truncatedDistance = Mathf.Floor(this.distance * 100f) / 100f;
this.distanceTxt.text = this.truncatedDistance + "m";
}
}
아래 코드는 일단 임시로 보스가 목적지에 도착했을 때 몇미터 남았는지 알려주기 위해서 임시로 만들어줬다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestMove : MonoBehaviour
{
[SerializeField] private GameObject giantGo;
[SerializeField] private GameObject goalGo;
[SerializeField] private float speed = 4f;
void Update()
{
this.transform.position = Vector3.MoveTowards(this.transform.position, this.goalGo.transform.position, this.speed);
}
}
'Giant vs Human 팀프로젝트 개발일지' 카테고리의 다른 글
[Giant vs Human 팀프로젝트, Mobile] 대포가 주변에 있으면 대포발사 버튼이 활성화되고 버튼을 누르면 포탄이 발사 (0) | 2023.11.29 |
---|---|
[Giant vs Human 팀프로젝트, Mobile] 조이스틱을 통한 이동, 버튼을 누르면 공격 (0) | 2023.11.29 |
[Giant vs Human 팀프로젝트, Meta Quest, VR, Oculus] 프로토타입 MapScene (0) | 2023.11.29 |
[Giant vs Human 팀프로젝트, Meta Quest, VR, Oculus] Haptic (0) | 2023.11.29 |
[Giant vs Human 팀프로젝트/Meta Quest, VR, Oculus] Haptic feedback(진동) (2) | 2023.11.22 |