19 lines
545 B
C#
19 lines
545 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class FollowCamera : MonoBehaviour
|
|
{
|
|
void Update()
|
|
{
|
|
if (Camera.main != null)
|
|
{
|
|
Transform camT = Camera.main.transform;
|
|
Vector3 viewPos = camT.transform.position + camT.transform.forward * 0f;
|
|
Vector3 cameraForward = new Vector3(camT.forward.x, 0, camT.forward.z);
|
|
transform.position = viewPos;
|
|
transform.rotation = Quaternion.LookRotation(cameraForward);
|
|
}
|
|
}
|
|
}
|