zoukankan      html  css  js  c++  java
  • mojing SDK根据坐标进行移动

    using UnityEngine;

    using UnityEngine.UI;

    using System.Collections;

    public class transforms : MonoBehaviour

    {

        public Text[] texts;//屏幕显示

        public Transform textss;//焦点坐标

        public GameObject[] cameras;//移动camera物体

        public int VSpeed=3;//移动速度

        private float times = 0;//间隔时间

        private float newTime_Distance = 0;//当前位移

        private float beforeTime_Distance = 0;//上一帧位移

        public void  newDistance()

        {

            //camera的Z轴变化距离

            beforeTime_Distance = textss.position.z;

        }

        void Update()

        {

            newDistance();//    每帧调一下

            if (Mathf.Abs(newTime_Distance - beforeTime_Distance) >= 0.001f)//当前帧距离-上一帧距离的绝对值>=时间

            {

                times = 0;

                newTime_Distance = beforeTime_Distance;

                texts[0].text = Time.time.ToString();

            }

            else

            {

                times += Time.deltaTime;//时间累加

                if (times >= 2)

                {

                    texts[3].text = times.ToString();

                    for (int i = 0; i < cameras.Length; i++)

                    {

                        //texts[0].text = (num_i++).ToString();

                        cameras[i].transform.Translate(Vector3.forward * VSpeed * Time.deltaTime);//向前移动

                    }

                }

            }

        }

    }

     注:此方法在mojing sdk for unity之后,通过轴坐标进行编写,如有更好的方法或者不懂,请评论在下方......

    支持个人观看使用,如商用或转载,请告知! -----萧朗(QQ:453929789 Email:xiaolang_xl@sina.com)
  • 相关阅读:
    月亮的背后
    2007经典妙语100句
    2007经典妙语100句
    VS C++ 2005的预生成事件及设置
    user case VS. user story
    如何用正确的方法来写出质量好的软件的75条体会
    用 Lucene 加速 Web 搜索应用程序的开发
    巾帼不让须眉——女生做运维 interesting topic
    ebean
    Download the 2.0.0 Release of the Scala IDE for Eclipse Scala IDE for Eclipse
  • 原文地址:https://www.cnblogs.com/XiaoLang0/p/9945790.html
Copyright © 2011-2022 走看看