Exemplo n.º 1
0
        public override void TryExitState(float DeltaTime)
        {
            if (CurrentAnimTag == MainTagHash) //Only try to exit when we are on flying
            {
                //Debug.Log("Try Exit Fly");

                if (CheckforWater)
                {
                    SwimState.CheckWater();
                    if (SwimState.IsInWater)
                    {
                        AllowExit();  //Let the other states to awake (Water)
                        return;
                    }
                }

                if (canLand)
                {
                    var MainPivot = animal.Main_Pivot_Point + animal.AdditivePosition;

                    if (debug)
                    {
                        Debug.DrawRay(MainPivot, animal.GravityDirection * animal.Height * LandMultiplier, Color.magenta);
                    }

                    int Hit = Physics.RaycastNonAlloc(MainPivot, animal.GravityDirection, LandHit, animal.Height * LandMultiplier, animal.GroundLayer, QueryTriggerInteraction.Ignore);

                    if (Hit > 0)
                    {
                        if (LandHit[0].distance < animal.Height)
                        {
                            animal.Grounded = true; //Means the animal is touching the ground
                        }
                        AllowExit();                //Let the other states to awake (Ground)
                        return;
                    }
                }

                switch (flyInput)
                {
                case FlyInput.Toggle:
                    if (ActiveState && InputValue)
                    {
                        AllowExit();
                        InputValue = false;
                    }
                    break;

                case FlyInput.Press:
                    if (ActiveState && !InputValue)
                    {
                        AllowExit();
                    }
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public override void TryExitState(float DeltaTime)
        {
            SwimState.CheckWater();
            SwimState.FindWaterLevel();

            if (SwimState.PivotAboveWater || !SwimState.IsInWater)
                AllowExit();
        }
Exemplo n.º 3
0
        public override bool TryActivate()
        {
            if (SwimState == null)
            {
                return(false);
            }

            if (!SwimState.IsActiveState)  //If we are not already swimming we need to check is we are on water
            {
                SwimState.CheckWater();
            }


            if (SwimState.IsInWater)
            {
                if (animal.MovementAxisSmoothed.y < -0.25f) //Means that Key Down is Pressed;
                {
                    IgnoreLowerStates = true;
                    return(true);
                }
            }
            return(false);
        }