-2
camera transform私は(Unity)C#でカメラを移動できないのはなぜですか?
ユニティのY軸のプレーヤーの動きに基づいてカメラを移動しようとしています。
しかし、それは動作しません...
どうしましたか?私はスクリプトの画像(C#)を添付しています。
そして、はい、私はメインカメラでこのスクリプトを添付しました。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraController : MonoBehaviour {
GameObject player;
// Use this for initialization
void Start() {
this.player = GameObject.Find("cat");
}
// Update is called once per frame
void Update() {
Vector3 playerPos = this.player.transform.position;
transform.position = new Vector3(
transform.position.x, playerPos.y, transform.position.z);
}
}