コード例 #1
0
ファイル: Jump.cs プロジェクト: mkinahan/Moonman
        private void Can_Jump_on_Cliff(float normalizedTime)
        {
            if (activeJump.CliffTime.IsInRange(normalizedTime))
            {
                var MainPivot = animal.Main_Pivot_Point;

                if (debug)
                {
                    Debug.DrawRay(MainPivot, -animal.Up * activeJump.CliffLandDistance * animal.ScaleFactor, Color.black);
                }

                if (Physics.Raycast(MainPivot, -animal.Up, out JumpRay, activeJump.CliffLandDistance * animal.ScaleFactor, animal.GroundLayer, QueryTriggerInteraction.Ignore))
                {
                    if (debug)
                    {
                        MTools.DebugTriangle(JumpRay.point, 0.1f, Color.black);
                    }

                    var TerrainSlope = Vector3.Angle(JumpRay.normal, animal.UpVector);
                    var DeepSlope    = TerrainSlope > animal.maxAngleSlope;

                    if (!DeepSlope)       //Jump to a jumpable cliff not an inclined one
                    {
                        Debugging("[Allow Exit] on a Cliff");
                        AllowExit();
                        animal.CheckIfGrounded();
                    }
                }
            }
        }
コード例 #2
0
ファイル: Jump.cs プロジェクト: mkinahan/Moonman
        /// <summary>Check if the animal can change to fall state if there's no future ground to land on</summary>
        private void Check_for_Falling()
        {
            AllowExit();
            OneCastingFall_Ray = true;

            if (activeJump.JumpLandDistance == 0)
            {
                animal.Grounded = true; //We are still on the ground
                return;                 //Meaning that is a False Jump (like Neigh on the Horse)
            }

            float RayLength = animal.ScaleFactor * activeJump.JumpLandDistance; //Ray Distance with the Scale Factor
            var   MainPivot = animal.Main_Pivot_Point;
            var   Direction = -animal.Up;


            if (activeJump.JumpLandDistance > 0) //greater than 0 it can complete the Jump on an even Ground
            {
                if (debug)
                {
                    Debug.DrawRay(MainPivot, Direction * RayLength, Color.red, 0.25f);
                }

                if (Physics.Raycast(MainPivot, Direction, out JumpRay, RayLength, animal.GroundLayer, QueryTriggerInteraction.Ignore))
                {
                    Debugging($"Min Distance to complete <B>[{ activeJump.name}]</B> - { JumpRay.distance:F4}");
                    if (debug)
                    {
                        MTools.DebugTriangle(JumpRay.point, 0.1f, Color.yellow);
                    }

                    var GroundSlope = Vector3.Angle(JumpRay.normal, animal.UpVector);

                    if (GroundSlope > animal.maxAngleSlope)     //if we found something but there's a deep slope
                    {
                        Debugging($"[AllowExit] Try to Land but the Sloope was too Deep. Slope: {GroundSlope:F2}");
                        animal.UseGravity = General.Gravity;
                        return;
                    }

                    IgnoreLowerStates = true;                           //Means that it can complete the Jump Ignore Fall Locomotion and Idle
                    Debugging($"Can finish the Jump. Going to Jump End");
                }
                else
                {
                    animal.UseGravity = General.Gravity;
                    Debugging($"[Allow Exit] - <B>Jump [{activeJump.name}] </B> Go to Fall..No Ground was found");
                }
            }
        }