---
title: "カメラを動かす"
content_type: tutorial
url: "https://learn.unity.com/tutorial/kamerawodong-kasu?language=ja"
language: ja
difficulty: beginner
duration_minutes: 10
unity_version:
  - "2020.2"
  - "2020.1"
  - "2019.4"
  - "2019.3"
supported_unity_versions:
  - name: "2020.2"
    url: "https://learn.unity.com/tutorial/kamerawodong-kasu.md?language=ja&version=2020.2"
  - name: "2020.1"
    url: "https://learn.unity.com/tutorial/kamerawodong-kasu.md?language=ja&version=2020.1"
  - name: "2019.4"
    url: "https://learn.unity.com/tutorial/kamerawodong-kasu.md?language=ja&version=2019.4"
  - name: "2019.3"
    url: "https://learn.unity.com/tutorial/kamerawodong-kasu.md?language=ja&version=2019.3"
available_languages:
  - name: "en"
    url: "https://learn.unity.com/tutorial/moving-the-camera-1.md?language=en"
  - name: "ja"
    url: "https://learn.unity.com/tutorial/kamerawodong-kasu.md?language=ja"
  - name: "ko"
    url: "https://learn.unity.com/tutorial/kamera-umjigigi.md?language=ko"
last_updated: "2026-08-04T14:21:20.000Z"
---

# カメラを動かす

「Roll-a-Ball」プロジェクトで Camera の位置を設定し、Player のスフィアを固定オフセットで追従するスクリプトを作成します。

この 3 つ目の「玉転がし（Roll-a-Ball）」チュートリアルでは、以下のことを行います：

- カメラ位置の設定
- Camera が Player のスフィアに fixed offset (固定オフセット)で追従するスクリプトを作成します。

## Materials

- [Set_the_Camera_position-Transcript.txt](https://unity-connect-prd.storage.googleapis.com/20200716/798f152b-b423-4b19-bd35-a5c598819b8c/Set_the_Camera_position-Transcript.txt)
- [Write_a_CameraController_script-Transcript.txt](https://unity-connect-prd.storage.googleapis.com/20200716/3cd8af1b-f4bb-416e-8347-9212c22812e6/Write_a_CameraController_script-Transcript.txt)
- [Reference_the_Player_GameObject-Transcript.txt](https://unity-connect-prd.storage.googleapis.com/20200716/ef137e2f-3ffd-40f8-9254-a9944eb95d4d/Reference_the_Player_GameObject-Transcript.txt)

## 1. カメラの位置の設定

[Video](http://www.youtube.com/watch?v=VziWP-dW4YE)

[ Download Transcript ](https://connect-prd-cdn.unity.com/20200716/798f152b-b423-4b19-bd35-a5c598819b8c/Set_the_Camera_position-Transcript.txt?_ga=2.73947674.943030393.1594530423-42703541.1592249374)

## 2. CameraController スクリプトの作成

[Video](http://www.youtube.com/watch?v=usSoznP2ioQ)

[Download Transcript](https://connect-prd-cdn.unity.com/20200716/3cd8af1b-f4bb-416e-8347-9212c22812e6/Write_a_CameraController_script-Transcript.txt?_ga=2.11648572.943030393.1594530423-42703541.1592249374)

## **CameraController スクリプト**

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour
{
    public GameObject player;

    private Vector3 offset;

    // Start is called before the first frame update
    void Start()
    {
        offset = transform.position - player.transform.position;
    }

    // Update is called once per frame
    void LateUpdate()
    {
        transform.position = player.transform.position + offset;
    }
}
```

## 3. プレイヤーゲームオブジェクトの参照

[Video](http://www.youtube.com/watch?v=WpPIOqNdi6c)

[ Download Transcript ](https://connect-prd-cdn.unity.com/20200716/ef137e2f-3ffd-40f8-9254-a9944eb95d4d/Reference_the_Player_GameObject-Transcript.txt?_ga=2.118984961.943030393.1594530423-42703541.1592249374)
