initial upload
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
[AddComponentMenu("Camera-Control/Smooth Look At")]
|
||||
public class SmoothLookAt : MonoBehaviour
|
||||
{
|
||||
public Transform target;
|
||||
|
||||
public float damping;
|
||||
|
||||
public bool smooth;
|
||||
|
||||
public SmoothLookAt()
|
||||
{
|
||||
damping = 6f;
|
||||
smooth = true;
|
||||
}
|
||||
|
||||
public virtual void LateUpdate()
|
||||
{
|
||||
if (GetComponent<NetworkView>().isMine)
|
||||
{
|
||||
}
|
||||
if ((bool)target)
|
||||
{
|
||||
if (smooth)
|
||||
{
|
||||
Quaternion to = Quaternion.LookRotation(target.position - transform.position);
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, to, Time.deltaTime * damping);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.LookAt(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Start()
|
||||
{
|
||||
if (GetComponent<NetworkView>().isMine && (bool)GetComponent<Rigidbody>())
|
||||
{
|
||||
GetComponent<Rigidbody>().freezeRotation = true;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Main()
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user