LoginSignup
1
0

More than 5 years have passed since last update.

カメラはプレーヤーの動きをフォローする

Posted at

カメラのオブジェクトはプライヤーの「Child」オブジェクトを設定する

data.png

この方法は動きの設定ができない、プライヤー全部変更の動きはカメラも変更されている。

この動きが3つうごきがあります。
・Transform。
・Scale
・Rotate

カメラで新しいスクリプトファイルを作る

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

public class followPlayer : MonoBehaviour {

    public Transform player;
    public Vector3 offset;

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

Screenshot_1.png

↑のコードを使ってそのカメラはプライヤーの動くをコピーすることができる。

        transform.position = player.position + offset;  

↑のコードはその「Transform」の動きをコピーするためのコードです。

GITHUB : https://github.com/andybit-okutama/Unity_Learn

1
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
1
0