Galaxy Generator

This commit is contained in:
mkadou
2023-06-05 15:34:37 +02:00
parent ec4cda81e9
commit 3db8cc2930
195 changed files with 47018 additions and 0 deletions

34
Assets/PlanetMove.cs Normal file
View File

@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlanetMove : MonoBehaviour
{
public float rotationSpeed = 1f; // Geschwindigkeit der Rotation
public float radius = 5f; // Radius des Kreises
private float angle = 0f; // Aktueller Winkel im Kreis
private Vector2 centerPosition; // Position des Zentrums des Kreises
// Start is called before the first frame update
void Start()
{
centerPosition = transform.parent.position; // Position des Zentrums
transform.position = GetPositionOnCircle(angle); // Setze die Startposition
}
// Update is called once per frame
void Update()
{
angle += rotationSpeed * Time.deltaTime; // Aktualisiere den Winkel basierend auf der Geschwindigkeit
transform.position = GetPositionOnCircle(angle); // Berechne die neue Position des Planeten
}
Vector3 GetPositionOnCircle(float angle)
{
float xPos = centerPosition.x + Mathf.Sin(angle) * radius; // X-Position auf dem Kreis
float yPos = centerPosition.y + Mathf.Cos(angle) * radius; // Y-Position auf dem Kreis
return new Vector3(xPos, yPos, 0f); // Position als Vektor zur<75>ckgeben
}
}