티스토리 뷰

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// Player에 카메라가 따라가도록 함.
public class CameraFollow : MonoBehaviour
{
    [SerializeField]
    private Transform targetToFollow; // 따라갈 target. (Player)

    private void Update()
    {
        transform.position = new Vector3(
            transform.position.x, // 나의 x pos
            targetToFollow.position.y, // Player의 y pos
            transform.position.z);
    }
}

스크립트를 camera에 attach

'유니티' 카테고리의 다른 글

Rigidbody, Freeze rotation  (0) 2021.01.21
배경 반복  (0) 2021.01.20
button을 프리팹으로 만들때 onclick parameter 사라질때  (0) 2021.01.17
특정 namespace not found  (0) 2021.01.17
Unet SyncVar  (0) 2021.01.09
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함