You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
513 B
C#

3 years ago
// CameraFacing.cs
// original by Neil Carter (NCarter)
// modified by Hayden Scott-Baron (Dock) - http://starfruitgames.com
// allows specified orientation axis
using UnityEngine;
using System.Collections;
public class CameraFacing : MonoBehaviour
{
public Camera cameraToLookAt;
void Awake() {
cameraToLookAt = Camera.main; }
void Update()
{
Vector3 v = cameraToLookAt.transform.position - transform.position;
v.x = v.z = 0.0f;
transform.LookAt(cameraToLookAt.transform.position - v);
}
}