You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
743 B
24 lines
743 B
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class LookGravity : MonoBehaviour |
|
{ |
|
Vector3 posBefore = Vector3.zero; |
|
//private void OnEnable() |
|
//{ |
|
// //transform.localeulerangles = vector3.zero; |
|
// //posBefore = transform.position; |
|
//} |
|
public void OnInitialized(Vector3 dir) |
|
{ |
|
//transform.rotation = Quaternion.LookRotation(dir, Vector3.up); |
|
//transform.rotation = Quaternion.Euler(0, Mathf.Atan2(dir.x, dir.z) * Mathf.Rad2Deg, 0); |
|
posBefore = dir; |
|
} |
|
private void FixedUpdate() |
|
{ |
|
transform.rotation = Quaternion.LookRotation(posBefore - transform.position, Vector3.up); |
|
posBefore = transform.position; |
|
} |
|
}
|
|
|