GameMain Script 작성
=> 오리 여러 마리 내보내기

오리 여러마리들을 prefab으로 만들었다.
이제 요 아이들은 GameMain에서 관리하여 일정 시간이 지날 때마다 오리 한 마리씩 출현하도록 설정하였다.

UI
=> 게이지 가득 차면 오리 내보내기


마침 게이지로 쓰기에 아주 적합하고 깜찍한 이미지를 발견했다.
위의 이미지는 frame으로 두고 밑에 이미지는 게이지를 채우는 용으로 사용하기로 했다.

또한 요 아이들을 관리하기 위한 UIMain 스크립트도 만들어놓고 UIMain을 GameMain이 관리하도록 설정하였다.
GameMain.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameMain : MonoBehaviour
{
[SerializeField]
private GameObject[] duckPrefabs;
[SerializeField]
private UIMain uiMain;
private float elapsedTime;
private float gaugeTime;
private int idx;
void Start()
{
Instantiate(duckPrefabs[idx++]);
this.gaugeTime = 10f;
}
// Update is called once per frame
void Update()
{
elapsedTime += Time.deltaTime;
if (elapsedTime > this.gaugeTime && idx<duckPrefabs.Length)
{
Instantiate(duckPrefabs[idx++]);
elapsedTime = 0;
}
this.uiMain.UpdateGauge(this.elapsedTime, this.gaugeTime);
}
}
UIMain.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UIMain : MonoBehaviour
{
[SerializeField]
private Image gaugeImg;
// Start is called before the first frame update
void Start()
{
gaugeImg.fillAmount = 0;
}
public void UpdateGauge(float time, float maxTime)
{
this.gaugeImg.fillAmount = time/maxTime;
}
}
결과
아쉬운 점
- 물의 굴절을 표현하지 못했다....
- 그림자가 물 안으로 들어가서 표현되어야 하는데 물의 표면에 그림자가 져버렸다.
- 여전히 어설픈 shader(물 표면이 안예쁜 각도가 존재, 파도 및 normal map부분을 수정할 필요를 느낌)
- 카메라 무브까지 구현했어야 했는데 미처 하지 못함...(shader를 공부하고 여기까지 할 시간이 없음을 깨달음)
- 부력 적용 방식의 미흡한 구현(floating object에 대한 아쉬움)
.
.
.
.
느낀 점
- 시간 할애(+분배)를 잘하자
- 전혀 모르는 영역을 구현하는 일이 생각보다 빡센 일이라는 걸 깨달았다.
- 개발일지 잘 쓰자,,ㅎ
'K-digital traning > 3D 콘텐츠 제작' 카테고리의 다른 글
Placid Plastic Duck Simulator - 개발일지6 (0) | 2023.10.11 |
---|---|
Placid Plastic Duck Simulator - 개발일지5 (0) | 2023.10.11 |
Placid Plastic Duck Simulator - 개발일지4 (0) | 2023.10.10 |
Placid Plastic Duck Simulator - 개발일지3 (0) | 2023.10.05 |
Placid Plastic Duck Simulator - 개발일지2 (0) | 2023.10.05 |