SanAndreasUnity/Assets/Scripts/Utilities/FaceTowardsCamera.cs

23 lines
526 B
C#
Raw Normal View History

2021-06-25 23:47:52 +00:00
using UnityEngine;
namespace SanAndreasUnity.Utilities
{
public class FaceTowardsCamera : MonoBehaviour
{
public Transform[] transformsToFace;
void Update()
{
var cam = Camera.current;
if (cam != null)
{
Vector3 f = -cam.transform.forward;
for (int i = 0; i < this.transformsToFace.Length; i++)
{
this.transformsToFace[i].forward = f;
}
}
}
}
}