博客
关于我
用Unity3D实现太阳系仿真
阅读量:677 次
发布时间:2019-03-17

本文共 2657 字,大约阅读时间需要 8 分钟。

目录


一.目的

1.想知道: 用Unity3D实现太阳系仿真

 

二.参考

1.用Unity3D实现太阳系仿真

  1. 总结:超级好,亲测有用

 

 

1.Unity制作太阳

  1. 总结:网上找不到太阳的资源,所以我自己做了一个

 

三.操作:一:完成:超级好,下面有上传的工程资源

1.下载地址

 

MyTestSolarSystem.rar  

  1. 这个是Unity2018.4.0f1
  2. 整个工程都在里面

 

1.运行结果

  1. 其他星球围绕太阳的转速必须不一样,且不在一个法平面上

运行结果

 

 

1.主要代码

  1. 总结:我这里没有使用到月球,所以将其注释了
using System.Collections;using System.Collections.Generic;using UnityEngine;public class MySunSystem : MonoBehaviour{    // Start is called before the first frame update    void Start()    {    }    // Update is called once per frame    void Update()    {        GameObject.Find("Sun").transform.Rotate(Vector3.up * Time.deltaTime * 5);        GameObject.Find("Mercury").transform.RotateAround(Vector3.zero, new Vector3(0.1f, 1, 0), 60 * Time.deltaTime);        GameObject.Find("Mercury").transform.Rotate(Vector3.up * Time.deltaTime * 1 / 58);        GameObject.Find("Venus").transform.RotateAround(Vector3.zero, new Vector3(0, 1, -0.1f), 55 * Time.deltaTime);        GameObject.Find("Venus").transform.Rotate(Vector3.up * Time.deltaTime * 10 / 243);        GameObject.Find("Earth").transform.RotateAround(Vector3.zero, new Vector3(0, 1, 0), 50 * Time.deltaTime);        GameObject.Find("Earth").transform.Rotate(Vector3.up * Time.deltaTime * 10);        只设置公转 不设置自传        //GameObject.Find("EarthClone").transform.RotateAround(Vector3.zero, new Vector3(0, 1, 0), 50 * Time.deltaTime);        令Moon相对与不自转的EarthClone公转        //GameObject.Find("Moon").transform.RotateAround(GameObject.Find("EarthClone").transform.position, new Vector3(0, 1, 0), 250 * Time.deltaTime);        //GameObject.Find("Moon").transform.Rotate(Vector3.up * Time.deltaTime * 10 / 27);        GameObject.Find("Mars").transform.RotateAround(Vector3.zero, new Vector3(0.2f, 1, 0), 45 * Time.deltaTime);        GameObject.Find("Mars").transform.Rotate(Vector3.up * Time.deltaTime * 10);        GameObject.Find("Jupiter").transform.RotateAround(Vector3.zero, new Vector3(-0.1f, 2, 0), 35 * Time.deltaTime);        GameObject.Find("Jupiter").transform.Rotate(Vector3.up * Time.deltaTime * 10 / 0.3f);        GameObject.Find("Saturn").transform.RotateAround(Vector3.zero, new Vector3(0, 1, 0.2f), 20 * Time.deltaTime);        GameObject.Find("Saturn").transform.Rotate(Vector3.up * Time.deltaTime * 10 / 0.4f);        GameObject.Find("Uranus").transform.RotateAround(Vector3.zero, new Vector3(0, 2, 0.1f), 15 * Time.deltaTime);        GameObject.Find("Uranus").transform.Rotate(Vector3.up * Time.deltaTime * 10 / 0.6f);        GameObject.Find("Neptune").transform.RotateAround(Vector3.zero, new Vector3(-0.1f, 1, -0.1f), 10 * Time.deltaTime);        GameObject.Find("Neptune").transform.Rotate(Vector3.up * Time.deltaTime * 10 / 0.7f);    }}

 

转载地址:http://sydhz.baihongyu.com/

你可能感兴趣的文章
MySQL Cluster 7.0.36 发布
查看>>
Multimodal Unsupervised Image-to-Image Translation多通道无监督图像翻译
查看>>
MySQL Cluster与MGR集群实战
查看>>
multipart/form-data与application/octet-stream的区别、application/x-www-form-urlencoded
查看>>
mysql cmake 报错,MySQL云服务器应用及cmake报错解决办法
查看>>
Multiple websites on single instance of IIS
查看>>
mysql CONCAT()函数拼接有NULL
查看>>
multiprocessing.Manager 嵌套共享对象不适用于队列
查看>>
multiprocessing.pool.map 和带有两个参数的函数
查看>>
MYSQL CONCAT函数
查看>>
multiprocessing.Pool:map_async 和 imap 有什么区别?
查看>>
MySQL Connector/Net 句柄泄露
查看>>
multiprocessor(中)
查看>>
mysql CPU使用率过高的一次处理经历
查看>>
Multisim中555定时器使用技巧
查看>>
MySQL CRUD 数据表基础操作实战
查看>>
multisim变压器反馈式_穿过隔离栅供电:认识隔离式直流/ 直流偏置电源
查看>>
mysql csv import meets charset
查看>>
multivariate_normal TypeError: ufunc ‘add‘ output (typecode ‘O‘) could not be coerced to provided……
查看>>
MySQL DBA 数据库优化策略
查看>>