Example #1
0
        private void DrawSurfaceNormal()
        {
            var color = isValidGround ? Color.green : Color.blue;

            DebugDraw.DebugArrow(groundPoint, surfaceNormal, color);
            //RuntimeDebugDraw.Draw.DrawRay(groundPoint, surfaceNormal, color);
            // Ground normal

            if (groundNormal != surfaceNormal)
            {
                color = Color.yellow;
                DebugDraw.DebugArrow(groundPoint, groundNormal, color);
            }
        }
        public static bool HasObstacleBetweenPlayerAndItem(PlayerEntity player, Vector3 targetCenter, GameObject item)
        {
            //  Logger.Debug("HasObstacleBeteenPlayerAndItem");
            if (null == player)
            {
                Logger.Error("player is null");
                return(true);
            }
            _castCount = 0;
            var startPoint = player.cameraStateOutputNew.FinalArchorPosition;
            int mask       = ~(UnityLayerManager.GetLayerMask(EUnityLayerName.UserInputRaycast) | UnityLayerManager.GetLayerMask(EUnityLayerName.Player)
                               | UnityLayerManager.GetLayerMask(EUnityLayerName.Vehicle) | UnityLayerManager.GetLayerMask(EUnityLayerName.NoCollisionWithBullet)
                               | UnityLayerManager.GetLayerMask(EUnityLayerName.NoCollisionWithEntity));

#if DEBUG_OBSTACLE
            DebugDraw.DebugArrow(startPoint, targetCenter - startPoint);
            if (null == _startGo)
            {
                _startGo = GameObject.CreatePrimitive(PrimitiveType.Cube);
                _startGo.GetComponent <Collider>().enabled = false;
                _targetGo = GameObject.CreatePrimitive(PrimitiveType.Cube);
                _targetGo.GetComponent <Collider>().enabled = false;
                _startGo.transform.localScale  = Vector3.one * 0.1f;
                _targetGo.transform.localScale = Vector3.one * 0.1f;
            }
            _startGo.transform.position  = startPoint;
            _targetGo.transform.position = targetCenter;
#endif
            var dir           = startPoint - targetCenter;
            var ray           = new Ray(targetCenter, dir.normalized);
            var inRangeOffset = -0.01f;
            var hits          = Physics.RaycastAll(ray, dir.magnitude - inRangeOffset, mask);
            foreach (var hit in hits)
            {
                Logger.DebugFormat("hit {0}", hit.collider.name);
                if (Ignore(hit, player, item))
                {
                    continue;
                }
                else
                {
                    OnObstacle(true);
                    //            Logger.Debug("onObstacle");
                    return(true);
                }
            }
            //    Logger.Debug("onObstacle");
            OnObstacle(false);
            return(false);
        }
Example #3
0
 public void DrawLastGroundHit()
 {
     //DebugDraw.EditorDrawArrow(GetLastGroundHitPoint(), GetLastGroundNormal(), Color.red);
     DebugDraw.DebugArrow(GetLastGroundHitPoint(), GetLastGroundNormal(), Color.red);
 }