(주) 망나니 힘집
카메라 시점 조절하기 본문
기본 idea : 오브젝트와 카메라 간의 거리 차이 계산하기
CameraMove 스크립트를 생성하고
카메라 이동에 관한건 LateUpdate() 에 코드를 넣는다 .
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraMove : MonoBehaviour
{
Transform playerTransform;
Vector3 Offset;
void Awake()
{
playerTransform = GameObject.FindGameObjectWithTag("player").transform;
Offset = transform.position - playerTransform.position;
}
// Update is called once per frame
void LateUpdate()
{
transform.position = playerTransform.position + Offset ;
}
}
'유니티 최고 > Unity' 카테고리의 다른 글
[유니티 이벤트 참여] 상품 수령 (2) | 2022.05.26 |
---|---|
[UNITY] UI- 텍스트, 이미지, 버튼, 앵커 (0) | 2022.01.18 |
[UNITY] 물리 충돌 이벤트와 트리거 이벤트 (0) | 2022.01.18 |
[UNITY] 오브젝트를 이동 (0) | 2022.01.18 |
[UNITY] rigidbody , collider , 재질, 물리재질 (0) | 2022.01.18 |