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)
  • 相关阅读:
    xib上的控件属性为什么要使用weak
    authenticating with the app store 一直卡住--问题记录
    ios-tableview加载卡顿的解决方案
    魔链的参考文档--移动应用之deeplink唤醒app
    iOS中Category和Extension 原理详解
    剑指offer 9-10:青蛙跳台阶与Fibonacii数列
    剑指offer 8:旋转数组的最小数字
    设计模式:单例模式(singleton)
    设计模式:工厂模式
    C++智能指针解析
  • 原文地址:https://www.cnblogs.com/XiaoLang0/p/9945790.html
Copyright © 2011-2022 走看看