Skip to content

Instantly share code, notes, and snippets.

@gremito
Last active March 12, 2020 17:06
Show Gist options
  • Save gremito/6fc4d280365b7efa7546423411c601e9 to your computer and use it in GitHub Desktop.
Save gremito/6fc4d280365b7efa7546423411c601e9 to your computer and use it in GitHub Desktop.
カメラ方向にキャラクタが向くスクリプト
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