не сложно
using UnityEngine; public class PlanetMovement : MonoBehaviour { public float A; public float P; public float C; public float angle; private Vector3 center; public float speed = 1; private float speed2 = 1; public GameObject Planet; //public GameObject PlanetСenter; void Update() { C = P + (A - P) / 2; if (angle >= 6.282722) { angle = 0; } angle += 0.001f * speed2; speed2 = (speed * C / (Vector3.Distance(Planet.transform.position, transform.position) / C)) / (A + P); float x = (A + P) / 2 * Mathf.Cos(angle); float y = C * Mathf.Sin(angle); center = new Vector3((A - P) / 2, 0, 0); Planet.transform.position = transform.position + center + new Vector3(x, 0, y); } }
A P это апогей и перигей
Обсуждают сегодня