Firstborn/Assets/PivecLabs/MiniMap/Scripts/orbitPlayer.cs
Schaken-Mods 959e80cf72 assets upload
assets upload description.
2023-03-28 12:16:30 -05:00

35 lines
756 B
C#

namespace PivecLabs.Minimap
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class orbitPlayer : MonoBehaviour {
public Transform PlayerTransform;
private Vector3 cameraOffset;
public float rotateSpeed = 5.0f;
void Start () {
cameraOffset = transform.position - PlayerTransform.position;
}
void LateUpdate () {
Quaternion camTurnAngle =
Quaternion.AngleAxis(Input.GetAxis("Mouse X") * rotateSpeed, Vector3.up);
cameraOffset = camTurnAngle * cameraOffset;
Vector3 newPos = PlayerTransform.position + cameraOffset;
transform.position = Vector3.Slerp(transform.position, newPos, 0.5f);
transform.LookAt(PlayerTransform);
}
}
}