示例#1
0
 public void LateUpdate()
 {
     //LocalSpeed = transform.InverseTransformDirection(m_Rigidbody.velocity);
     Speed                  = (this.transform.position - LastPosition) / Time.deltaTime;
     LocalSpeed             = transform.InverseTransformDirection(Speed);
     carController.Skidding = Vector3.Angle(this.transform.forward, Speed) > 2;
     if (ValueAdjust.JudgeRange(Speed.magnitude, LastSpeed, 1f))
     {
         AccelInput = ValueAdjust.Lerp(AccelInput, 0, Time.deltaTime);
         BrakeInput = ValueAdjust.Lerp(BrakeInput, 0, Time.deltaTime);
     }
     else
     {
         if (Speed.magnitude > LastSpeed)
         {
             AccelInput = ValueAdjust.Lerp(AccelInput, 1, Time.deltaTime);
         }
         else
         {
             AccelInput = ValueAdjust.Lerp(AccelInput, 0, Time.deltaTime);
         }
         BrakeInput = ValueAdjust.Lerp(BrakeInput, 1 - AccelInput, Time.deltaTime);
     }
     CalculateRevs();
     carController.Revs = RevsPercent;
     LastPosition       = this.transform.position;
     LastSpeed          = Speed.magnitude;
 }
示例#2
0
        /// <summary>
        /// 测试副屏是否在主屏下方
        /// </summary>
        void TestDown()
        {
            Vector2 mousePosition = Input.mousePosition;
            bool    result        = ValueAdjust.JudgeRange(Display.displays[0].systemHeight - mousePosition.y, TestMousePos[3].y, ErrorRange);
            string  info          = "Target:" + TestMousePos[3] + " Mouse:" + mousePosition + " 副屏在主屏下方:" + result + " \r\n";

            Debug_T.Log(info);
            if (result)
            {
                SetPosition(0, 1);//下
            }
            else
            {
                SetPosition(0, 0);//都不符合,放在主屏
            }
        }
示例#3
0
        /// <summary>
        /// 测试副屏是否在主屏上方
        /// </summary>
        void TestUp()
        {
            Vector2 mousePosition = Input.mousePosition;
            bool    result        = ValueAdjust.JudgeRange(Display.displays[0].systemHeight - mousePosition.y, TestMousePos[2].y, ErrorRange);
            string  info          = "Target:" + TestMousePos[2] + " Mouse:" + mousePosition + " 副屏在主屏上方:" + result + " \r\n";

            Debug_T.Log(info);
            SetOverrideMousePos(TestMousePos[3].x, TestMousePos[3].y, true);
            if (result)
            {
                SetPosition(0, -1);//上
            }
            else
            {
                Invoke(nameof(TestDown), 0.1f);//判定下
            }
        }
示例#4
0
        /// <summary>
        /// 测试副屏是否在主屏左方
        /// </summary>
        void TestLeft()
        {
            Vector2 mousePosition = Input.mousePosition;
            bool    result        = ValueAdjust.JudgeRange(mousePosition.x, TestMousePos[1].x, ErrorRange);
            string  info          = "Target:" + TestMousePos[1] + " Mouse:" + mousePosition + " 副屏在主屏左方:" + result + " \r\n";

            Debug_T.Log(info);
            SetOverrideMousePos(TestMousePos[2].x, TestMousePos[2].y, true);
            if (result)
            {
                SetPosition(-1, 0);//左
            }
            else
            {
                Invoke(nameof(TestUp), 0.1f);//判定上
            }
        }