Example #1
0
 protected override void CustomRefreshGravity()
 {
     //base.CustomRefreshGravity();
     if (TransTool.IsNull(mTrans) == false)
     {
         bool    isHit  = false;
         Vector3 hitPos = RaycastTool.Raycast(mTrans, Vector3.down, LayerName.Gound, out isHit);
         if (!isHit)
         {
             if (Vector3.Distance(Pos, new Vector3(Pos.x, 0, Pos.z)) > 0)
             {
                 isHit = true;
             }
         }
         if (isHit)
         {
             if (Vector3.Distance(Pos, hitPos) > 0)
             {
                 if (GravityTabTime == 0)
                 {
                     GravityTabTime = Time.realtimeSinceStartup;
                 }
             }
             else
             {
                 GravityTabTime = 0;
             }
         }
     }
 }
Example #2
0
        /// <summary>
        /// 刷新自由落体
        /// </summary>
        protected virtual void CustomRefreshGravity()
        {
            bool    isHit  = false;
            Vector3 hitPos = RaycastTool.Raycast(mPos, Vector3.down, LayerName.Gound, out isHit);

            if (isHit)
            {
                var dis = Vector3.Distance(mPos, hitPos);
                if (dis > 0)
                {
                    mGravityTabTime = Time.realtimeSinceStartup;
                }
                else if (dis < 0)
                {
                    mGravityTabTime = 0;
                    mPos            = hitPos;
                }
            }
        }