-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSolarSystem.cs
38 lines (33 loc) · 1022 Bytes
/
SolarSystem.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SolarSystem : MonoBehaviour
{
[Header("Settings")]
[SerializeField] private float _SpeedMultiplier = 1;
[Header("Planets")]
[SerializeField] private List<SolarSystem_Planet> _Planet = new List<SolarSystem_Planet>();
private void Start()
{
for (int i = 0; i < _Planet.Count; i++)
{
_Planet[i].CalculatedSpeed = _Planet[i].Days * 0.4115f;
}
}
void Update()
{
for (int i = 0; i < _Planet.Count; i++)
{
_Planet[i].Center.Rotate(new Vector3(_Planet[i].RotationSpeed.x, _Planet[i].RotationSpeed.y, _Planet[i].RotationSpeed.z) * _Planet[i].CalculatedSpeed * _SpeedMultiplier * Time.deltaTime);
}
}
}
[System.Serializable]
public class SolarSystem_Planet
{
public string Names;
public Transform Center;
public Vector3 RotationSpeed;
public float Days;
[HideInInspector] public float CalculatedSpeed;
}