31 lines
655 B
C#
31 lines
655 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class FacingCamera : MonoBehaviour
|
|
{
|
|
Transform[] childs;
|
|
private Transform cameraMain;
|
|
private void Awake()
|
|
{
|
|
cameraMain = GameObject.FindGameObjectWithTag("Camera").transform;
|
|
}
|
|
void Start()
|
|
{
|
|
childs = new Transform[transform.childCount];
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
{
|
|
childs[i] = transform.GetChild(i);
|
|
}
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
for (int i = 0; i < childs.Length; i++)
|
|
{
|
|
childs[i].rotation = cameraMain.rotation;
|
|
}
|
|
}
|
|
}
|
|
|