Example #1
0
        public virtual void DrawBoundingBox()
        {
            var characterTransformToCapsuleBottom = _motor.CharacterTransformToCapsuleBottom;
            var characterTransformToCapsuleTop    = _motor.CharacterTransformToCapsuleTop;

            //DebugDraw.EditorDrawCapsule(transform.position + transform.rotation * characterTransformToCapsuleBottom, transform.position + transform.rotation * characterTransformToCapsuleTop, radius, Color.magenta);
            DebugDraw.DebugCapsule(transform.position + transform.rotation * characterTransformToCapsuleBottom, transform.position + transform.rotation * characterTransformToCapsuleTop, Color.magenta, radius);
        }
        public void DrawBoundingBox()
        {
            var characterTransformToCapsuleBottom = center + (-direction * (height * 0.5f));
            var characterTransformToCapsuleTop    = center + (direction * (height * 0.5f));

            //DebugDraw.EditorDrawCapsule(transform.position + transform.rotation * characterTransformToCapsuleBottom, transform.position + transform.rotation * characterTransformToCapsuleTop, radius, Color.magenta);
            DebugDraw.DebugCapsule(transform.position + transform.rotation * characterTransformToCapsuleBottom, transform.position + transform.rotation * characterTransformToCapsuleTop, Color.magenta, radius);
        }
Example #3
0
        public static void DrawCollider(CharacterController collider, Color color, float duration = 0.0f, bool depthTest = true)
        {
            Vector3 point1, point2;
            float   radius;
            var     height = collider.height;

            radius = collider.radius;
            var center = collider.center;

            GetDebugDrawTypeCapsule(collider.transform.position, collider.transform.rotation, height, radius, center, Vector3.up, out point1, out point2);
            DebugDraw.DebugCapsule(point1, point2, color, radius, duration, depthTest);
        }
Example #4
0
        private static void DrawBoundingBox(KinematicCharacterMotor motor)
        {
            var characterTransformToCapsuleBottom = motor.CharacterTransformToCapsuleBottom;
            var characterTransformToCapsuleTop    = motor.CharacterTransformToCapsuleTop;

//            DebugDraw.EditorDrawCapsule(motor.TransientPosition + motor.TransientRotation * characterTransformToCapsuleBottom,
//                motor.TransientPosition + motor.TransientRotation * characterTransformToCapsuleTop, motor.CapsuleRadius,
//                Color.magenta);
            DebugDraw.DebugCapsule(motor.TransientPosition + motor.TransientRotation * characterTransformToCapsuleBottom,
                                   motor.TransientPosition + motor.TransientRotation * characterTransformToCapsuleTop,
                                   Color.magenta, motor.CapsuleRadius);
        }
Example #5
0
        private static bool IsHitGround(PlayerEntity playerEntity, float dist)
        {
            var        gameObject     = playerEntity.RootGo();
            var        prevLayer      = gameObject.layer;
            var        prev           = IntersectionDetectTool.SetColliderDisable(gameObject);
            var        playerPosition = gameObject.transform.position;
            var        playerRotation = gameObject.transform.rotation;
            var        controller     = playerEntity.characterContoller.Value;
            var        valueRadius    = playerEntity.characterContoller.Value.radius;
            var        isHit          = false;
            RaycastHit outHit;

            if (UseSphereCast(controller))
            {
                //use sphere cast
                var position = playerPosition + playerRotation * new Vector3(0f, valueRadius, 0f);

//            DebugDraw.DebugWireSphere(startPoint, Color.red, CastRadius, 1f);
//            DebugDraw.DebugWireSphere(startPoint + new Vector3(0,targetHeight - CastRadius - LiftUp,0), Color.magenta, CastRadius, 1f);
                isHit = PhysicsCastHelper.SphereCast(position, CastRadius, Vector3.down, out outHit, dist,
                                                     UnityLayers.AllCollidableLayerMask, QueryTriggerInteraction.Ignore, 0.1f);
                if (!isHit)
                {
                    //DebugDraw.DebugWireSphere(position + (isHit ? Vector3.down * outHit.distance : Vector3.down * dist),isHit ? Color.green : (playerEntity.characterContoller.Value.isGrounded ? Color.magenta : Color.red) ,CastRadius, isHit ? 0f:60f);
                }
            }
            else
            {
                Vector3 point1, point2;
                float   radius;
                var     height = controller.height;
                radius = controller.radius;
                var center = controller.center;
                PhysicsCastHelper.GetCapsule(controller.transform.position, controller.transform.rotation, height, radius, center, controller.direction, out point1, out point2);
                isHit = PhysicsCastHelper.CapsuleCast(point1, point2, radius, Vector3.down, out outHit, dist,
                                                      UnityLayers.AllCollidableLayerMask, QueryTriggerInteraction.Ignore, 0.1f);
                if (!isHit && false)
                {
                    PhysicsCastHelper.GetDebugDrawTypeCapsule(controller.transform.position, controller.transform.rotation, height, radius, center, controller.direction, out point1, out point2);
                    DebugDraw.DebugCapsule(point1 + (isHit ? Vector3.down * outHit.distance : Vector3.down * dist),
                                           point2 + (isHit ? Vector3.down * outHit.distance : Vector3.down * dist),
                                           isHit ? Color.green : (playerEntity.characterContoller.Value.isGrounded ? Color.magenta : Color.red),
                                           radius,
                                           isHit ? 0f:60f
                                           );
                }
            }


            IntersectionDetectTool.RestoreCollider(gameObject, prev);
            return(isHit);
        }