用Unity3D实现太阳系仿真

目录

一.目的

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

二.参考

1.用Unity3D实现太阳系仿真

1.Unity制作太阳

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

1.下载地址

1.运行结果

1.主要代码


一.目的

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

 

二.参考

1.用Unity3D实现太阳系仿真

用Unity3D实现太阳系仿真

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

 

 

1.Unity制作太阳

https://blog.csdn.net/qq_40544338/article/details/116884263?spm=1001.2014.3001.5501

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

 

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

1.下载地址

 

MyTestSolarSystem.rar  https://download.csdn.net/download/qq_40544338/18772751

  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);
    }

}

 

  • 2
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值