wangguan
2020-12-04 7663d2a2fe0dd97e1933354553827d29d66f3b45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
/**
 * 小怪看向SceneCamera
 * @Author: chenxin
 * @Date: 2020-11-12 17:46:56
 */
namespace KTGMGemClient
{
    public class LookAtSceneCamera : MonoBehaviour
    {
        private Camera sceneCamera;
 
        // Start is called before the first frame update
        private void Start()
        {
            sceneCamera = GameObject.Find("SceneCamera3D").GetComponent<Camera>();
 
            Invoke("LookAtCamera",0.2f);
        }
 
        public Vector3 offect = new Vector3(0, 0.07f, 0.04f);
 
        private void LookAtCamera()
        {
            transform.LookAt(transform.position + sceneCamera.transform.rotation * Vector3.forward,
                sceneCamera.transform.rotation * Vector3.up);
 
            transform.localPosition = offect;
        }
 
        // Update is called once per frame
        private void Update()
        {
 
        }
 
        //Orient the camera after all movement is completed this frame to avoid jittering
        void LateUpdate()
        {
            // transform.LookAt(sceneCamera.transform);
 
        }
    }
}