LoginSignup
4
0

More than 3 years have passed since last update.

cinemachine

Last updated at Posted at 2020-12-14

Cinemachineについて

Unity公式のAsset。PackageManagerからダウンロードできる(2018.4.17f1 以降)。
カメラの挙動をコントロール(オブジェクトを追純したり、決められたルートを走らせたり)できてとても便利。
Timelineとの連携ができてとても良いそう(自分は使ってない)。
untiy公式がcinemachineをフル活用して作ったプロモーションproject BoatRace

活用法(自分の作品への使用例)

CarRace 一人称と三人称を切り替えられるところがポイント
CarPV(CM風) 車の躍動感が素晴らしい

Cinemachine Priorityを活用する

複数のバーチャルカメラを切り替えるためには、InspectorにあるPriorityという数値を変更します。数値が高いカメラが優先されてGame画面に表示されます。
今回はPriorityをScript上から変更し、カメラを楽に切り替える仕組みにしました。

ChangeCamera.cs

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

public class ChangeCamera : MonoBehaviour
{

    public CinemachineVirtualCamera vcamera;

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            if (vcamera.Priority == 10)
            {
                vcamera.Priority = 80;
                return;
            }

            if(vcamera.Priority == 80)
            {
                vcamera.Priority = 10;

            }
        }


        }
    }

最後に

3Dゲームを作りたいなら絶対導入してください。機能が豊富で使いやすいです。

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0