Moving the Camera

확인 완료한 버전: 5

-

난이도: 초급

Moving the camera relative to the player.

Moving the Camera

초급 Roll-a-ball tutorial

트랜스크립트

CameraController

Code snippet

using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {

    public GameObject player;

    private Vector3 offset;

    void Start ()
    {
        offset = transform.position - player.transform.position;
    }
    
    void LateUpdate ()
    {
        transform.position = player.transform.position + offset;
    }
}

관련 자습서