카메라에 W, S 누르면 화면 이동하는 스크립트 넣기
W, S키를 누르면 지정된 위치로 이동한다.
S키 하나만 만들었음
카메라 구성
카메라 스크립트 CameraMain에 enum으로 Down 상태일 때, Normal 상태일 때, MyCard, EnemyCard들을 보고있는 상태일 때 더 이상 아래로 내려가지 않게 해주려고 일단 enum으로 구성했다.
private enum eCameraType
{
Down, Normal, MyCard, EnemyCard
}
private eCameraType cameraType;
private void Start()
{
this.cameraType = eCameraType.Normal;
}
카메라 이동
아직 Normal을 보고있는 상태일 때 S키를 누르면 작동하게 하였는데 다른 상태일 때도 작동하게 할 것이고
Down상태에서는 S키를 눌러도 안내려가게 할 것이고, EnemyCard상태에서는 W키를 눌러도 안 올라가게 할 것이다.
아래 스크립트는 이 과정을 하기 위한 밑 작업이다.
void Update()
{
switch((int)cameraType)
{
case 0: //카메라 시점 아래 보고 있을 때
if (Input.GetKeyDown(KeyCode.W))
{
cameraType = eCameraType.Normal;
}
break;
case 1: //카메라 보통 상태일 때
if (Input.GetKeyDown(KeyCode.S))
{
this.gameObject.transform.eulerAngles = new Vector3(35, 0, 0);
cameraType = eCameraType.Down;
}
else if(Input.GetKeyDown(KeyCode.W))
{
cameraType = eCameraType.MyCard;
}
break;
case 2: //카메라가 내 카드 보고있을 때
if (Input.GetKeyDown(KeyCode.S))
{
cameraType = eCameraType.Normal;
}
else if (Input.GetKeyDown(KeyCode.W))
{
cameraType = eCameraType.EnemyCard;
}
break;
case 3: //카메라가 적 카드 보고있을 때
if (Input.GetKeyDown(KeyCode.S))
{
cameraType = eCameraType.MyCard;
}
break;
}
}
}
'Inscryption 모작 개발일지' 카테고리의 다른 글
Inscryption 모작 개발일지 - 4일차 (0) | 2023.10.11 |
---|---|
Inscryption 모작 개발일지 - 3일차 (0) | 2023.10.10 |
Inscryption 모작 개발일지 - 2일차 [ 카드 ], 버튼누르면 세팅, 기존 씬으로 옮기기 (0) | 2023.09.25 |
Inscryption 모작 개발일지 - 2일차 [카메라 시점변환] / enum, Lerp (0) | 2023.09.25 |
Inscryption 모작 개발일지 방향성 (0) | 2023.09.21 |