mergemilitary/Assets/Art/AAsucai/ExplosiveLLC/SuperCharacterController/Code/Gravity.cs

18 lines
467 B
C#
Raw Normal View History

2022-05-18 13:44:19 +00:00
using UnityEngine;
/// <summary>
/// Rotates a this transform to align it towards the target transform's position.
/// </summary>
public class Gravity : MonoBehaviour
{
[SerializeField]
Transform planet;
void Update()
{
Vector3 dir = (transform.position - planet.position).normalized;
GetComponent<PlayerMachine>().RotateGravity(dir);
transform.rotation = Quaternion.FromToRotation(transform.up, dir) * transform.rotation;
}
}