Skip to content

Instantly share code, notes, and snippets.

@nabesi777
Created September 13, 2018 11:33
Show Gist options
  • Save nabesi777/1c686d19a8ddc6624bbb0c1f5421a2c6 to your computer and use it in GitHub Desktop.
Save nabesi777/1c686d19a8ddc6624bbb0c1f5421a2c6 to your computer and use it in GitHub Desktop.
Face_To_Camera_2 C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FaceTo : MonoBehaviour {
public GameObject cube; //cubeを入れる箱を作成
public Camera mainCamera; //カメラを入れる箱を作成
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
//カメラをcubeの方向へ向ける transform.LookAT
//transform.LoolAt関数はオブジェクトを対象の方向へ向ける
mainCamera.transform.LookAt(cube.transform);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment