• CR开发笔记-2基础飞机的搭建以及测试代码


    好吧!今天没有建模,主要是美术细胞死了。

    处于一种劳累的状态。

    快速说一下今天的进度

    啊,这就是一个逗比飞机的基本骨架。

    没有什么好解释的。

    这里开始坑人了,上面的红色箭头指的是是否利用重力,这里由于是飞船么,宇宙中暂时没有重力,所以去掉。

    下面是的红红的是是否符合经典物理动力学。

    (说白了就是是否可以支持Force,今天我以为他是是否失重,然后调了半天代码%>_<%)

    然后贴代码。

    public class levelRun : MonoBehaviour {

    // Use this for initialization

    void Start () {

            this.gameObject.AddComponent("standardShipControl");

    }

    // Update is called once per frame

    void Update () {

    }

    }

    这个文件绑定在每个关卡场景的levelRun里面,在这里是载入一个标准飞船控制脚本。以后还会载入各种GUI之类的文件,这样让整个体系更灵活化,便于操作。

    下面是标准操作的一开始定义代码

    public class standardShipControl : MonoBehaviour {

        GameObject ship;

        Transform frontLeftPropeller;

        Transform frontRightPropeller;

        Transform backLeftPropeller;

        Transform backRightPropeller;

        Transform backPropeller;

        Transform frontPropeller;

        Transform frontWing;

        Transform backWing;

    // Use this for initialization

    void Start () {

            ship = GameObject.Find("ship");

            frontWing = transform.Find("/ship/frontWing");

            backWing = transform.Find("/ship/backWing");

            backLeftPropeller = transform.Find("/ship/backLeftWingPropeller");

            backRightPropeller = transform.Find("/ship/backRightWingPropeller");

            frontLeftPropeller = transform.Find("/ship/frontLeftWingPropeller");

            frontRightPropeller = transform.Find("/ship/frontRightWingPropeller");

            backPropeller = transform.Find("/ship/backPropeller");

            frontPropeller = transform.Find("/ship/frontPropeller");

    }

    // Update is called once per frame

    void Update () {

    }

        void FixedUpdate(){

             if(Input.GetKey("w"))

            {

                //UnityEngine.Debug.Log("he");

               ship.rigidbody.AddForceAtPosition(ship.transform.forward, backPropeller.position);

            }

        }

    }

    需要注意的就是在外部加载的脚本,貌似在transform里的参数在前面需要加一个/否则找不到,原来加不加是一样的。

    重要函数UnityEngine.Debug.Log("he")调试。

    ship.rigidbody.AddForceAtPosition(ship.transform.forward, backPropeller.position);在固定点施加力。

    结束!睡觉!

    PS:(程序员不适合画画)

  • 相关阅读:
    机器学习【九】数据表达与特征工程
    机器学习【八】数据预处理、降维、特征提取及聚类
    机器学习【七】神经网络
    机器学习【六】支持向量机SVM——专治线性不可分
    机器学习【五】随机森林
    机器学习【四】决策树
    单片机简介 & 点亮LED & 流水灯 & 电路基础
    PHP表单
    机器学习【三】朴素贝叶斯
    PHP 【六】
  • 原文地址:https://www.cnblogs.com/zuoguangxing/p/3836138.html
Copyright © 2020-2023  润新知