using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EightStar : MonoBehaviour
{
//拖拽预设体
[Header("太阳")]
public GameObject Sun;
[Header("水星")]
public GameObject Meacury;
[Header("金星")]
public GameObject Venus;
[Header("地球")]
public GameObject Earth;
[Header("火星")]
public GameObject Mars;
[Header("木星")]
public GameObject Jupiter;
[Header("土星")]
public GameObject Saturn;
[Header("天王星")]
public GameObject DawnStar;
[Header("海王星")]
public GameObject Neptune;
[Header("月球")]
public GameObject Moon;
//定义星球
private GameObject sun;
private GameObject meacury;
private GameObject venus;
private GameObject earth;
private GameObject mars;
private GameObject jupiter;
private GameObject saturn;
private GameObject dawnStar;
private GameObject neptune;
private GameObject moon;
private void Start()
{
//在固定位置生成星球,且星球的旋转数值为初始值
sun=Instantiate(Sun, new Vector3(-50, 0, 0), Quaternion.identity);
meacury=Instantiate(Meacury, new Vector3(-40, 0, 0), Quaternion.identity);
venus=Instantiate(Venus, new Vector3(-30, 0, 0), Quaternion.identity);
earth=Instantiate(Earth, new Vector3(-20, 0, 0), Quaternion.identity);
mars=Instantiate(Mars, new Vector3(-10, 0, 0), Quaternion.identity);
jupiter=Instantiate(Jupiter, new Vector3(0, 0, 0), Quaternion.identity);
saturn=Instantiate(Saturn, new Vector3(10, 0, 0), Quaternion.identity);
dawnStar=Instantiate(DawnStar, new Vector3(20, 0, 0), Quaternion.identity);
neptune=Instantiate(Neptune, new Vector3(30, 0, 0), Quaternion.identity);
moon = Instantiate(Moon, new Vector3(-15, 0, 0), Quaternion.identity);
//设置月球的父物体为地球
moon.transform.SetParent(earth.transform);
}
private void Update()
{
//星球绕太阳公转
meacury.transform.RotateAround(new Vector3(-50,0,0), Vector3.up, Time.deltaTime*10);
venus.transform.RotateAround(new Vector3(-50,0,0), Vector3.up, Time.deltaTime*20);
earth.transform.RotateAround(new Vector3(-50,0,0), Vector3.up, Time.deltaTime*30);
mars.transform.RotateAround(new Vector3(-50,0,0), Vector3.up, Time.deltaTime*20);
jupiter.transform.RotateAround(new Vector3(-50,0,0), Vector3.up, Time.deltaTime*20);
saturn.transform.RotateAround(new Vector3(-50,0,0), Vector3.up, Time.deltaTime*50);
dawnStar.transform.RotateAround(new Vector3(-50,0,0), Vector3.up, Time.deltaTime*10);
neptune.transform.RotateAround(new Vector3(-50,0,0), Vector3.up, Time.deltaTime*30);
moon.transform.RotateAround(new Vector3(-20,0,0), Vector3.up, Time.deltaTime*10);
//地球自转
earth.transform.Rotate(Vector3.up,Space.World);
}
}