init
This commit is contained in:
commit
e0a842f222
796 changed files with 361371 additions and 0 deletions
20
Assets/Scripts/LookAtMovement.cs
Normal file
20
Assets/Scripts/LookAtMovement.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LookAtMovement : MonoBehaviour
|
||||
{
|
||||
private Vector3 lastPos = Vector3.zero;
|
||||
public float slerpAlpha = 0.025f;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(transform.position - lastPos, Vector3.up), slerpAlpha);
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
lastPos = transform.position;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue