Last active
March 12, 2020 17:06
-
-
Save gremito/6fc4d280365b7efa7546423411c601e9 to your computer and use it in GitHub Desktop.
カメラ方向にキャラクタが向くスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
// Camera to AddComponent | |
public class LookAt : MonoBehaviour | |
{ | |
[SerializeField] | |
GameObject unitychan; | |
void Start() | |
{ | |
// The direction of the camera turns to the character. | |
// var targetPos = unitychan.transform.position; | |
// targetPos.y = transform.position.y; | |
// transform.LookAt(unitychan.transform); | |
var targetPos = transform.position; | |
targetPos.y = unitychan.transform.position.y; | |
unitychan.transform.LookAt(transform); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment