28 lines
		
	
	
		
			499 B
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			499 B
		
	
	
	
		
			C#
		
	
	
	
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| 
 | |
| public class AlwaysLookAt : MonoBehaviour
 | |
| {
 | |
|     [SerializeField] Transform mLookTrans;
 | |
| 
 | |
|     private Transform mTrans;
 | |
| 
 | |
|     private void Awake()
 | |
|     {
 | |
|         mTrans = transform;
 | |
|         if (mLookTrans == null)
 | |
|         {
 | |
|             mLookTrans = Camera.main.transform;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private void Update()
 | |
|     {
 | |
|         if (mLookTrans != null)
 | |
|         {
 | |
|             mTrans.LookAt(mLookTrans);
 | |
|         }
 | |
|     }
 | |
| }
 |