using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class DataCanvas : MonoBehaviour { [Header("References")] [SerializeField] private RotationController m_ship; [SerializeField] private Transform m_eyes; [SerializeField] private TextMeshProUGUI text; [SerializeField] private Canvas m_canvas; // Start is called before the first frame update void Start() { if (m_ship == null) m_ship = FindObjectOfType(); } // Update is called once per frame void Update() { RotationController(); DisplayGravity(); } public void RotationController() { Vector3 _directionToEyes = (transform.position - m_eyes.position).normalized; float _alignment = (Vector3.Dot(transform.forward, _directionToEyes) + 1)/2; float _backAngle = Vector3.Angle(_directionToEyes, transform.forward); float _rotationValue = Mathf.Lerp(180-_backAngle, 0, 0); //m_canvas.transform.localRotation = Quaternion.Euler(_rotationValue, 0, 0); //text.text = _alignment.ToString("0.00"); } public void DisplayGravity() { float force = m_ship.GetGravityAtPoint(transform.position).magnitude; text.text = $"{force.ToString("0.00")} m/s"; } }