31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
|
using UnityEngine;
|
||
|
|
||
|
namespace Interactive
|
||
|
{
|
||
|
public class PlayerMenu : MonoBehaviour
|
||
|
{
|
||
|
private Camera _cam;
|
||
|
private float _smoothSpeed = 3f;
|
||
|
private Transform _playerTransform;
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
_cam = Camera.main;
|
||
|
_playerTransform = transform.GetComponentInParent<Player.Player>().transform;
|
||
|
}
|
||
|
|
||
|
void Update()
|
||
|
{
|
||
|
Vector3 direction = transform.position - _cam.transform.position;
|
||
|
|
||
|
Quaternion targetRotation = Quaternion.LookRotation(direction);
|
||
|
|
||
|
Transform transform1;
|
||
|
(transform1 = _cam.transform).rotation = Quaternion.Slerp(_cam.transform.rotation, targetRotation, _smoothSpeed * Time.deltaTime);
|
||
|
transform.LookAt(transform1);
|
||
|
|
||
|
var targetPos = _playerTransform.position + _playerTransform.up * 0.638f + _playerTransform.forward * 0.27f;
|
||
|
transform.position += (targetPos - transform.position) * Time.deltaTime * 4f;
|
||
|
}
|
||
|
}
|
||
|
}
|