void FixedUpdate()
    {
        CheckForConfusion();

        if (movementFrozen)
        {
            freezeTimer.Decrement();

            if (freezeTimer.Count() == 0)
            {
                movementFrozen = false;
                fmState        = FMState.None;
            }

            FrozenMove();
        }

        if (justJumped)
        {
            jumpTimer.Decrement();

            if (jumpTimer.Count() == 0)
            {
                justJumped = false;
                jumpTimer.Reset();
            }
        }

        switch (myState)
        {
        case AIState.Idle:
            Idle();
            break;

        case AIState.CrateAvailable:
            GoToCrate();
            break;

        case AIState.IHaveBomb:
            IHaveBomb();
            break;

        case AIState.IThrewBomb:
            IThrewBomb();
            break;

        case AIState.SomeoneElseStuck:
            RunFromStuckPlayer();
            break;

        case AIState.SomeoneElseHasBomb:
            SomeoneElseHasBomb();
            break;

        case AIState.BombOnGround:
            GoToBomb();
            break;

        case AIState.IAmStuck:
            IAmStuck();
            break;

        case AIState.SomeoneElseThrewBomb:
            AvoidBombMidAir();
            break;

        case AIState.ConfusedState:
            Confused();
            break;
        }

        //always check for if u get stuck
        if (myState != AIState.IAmStuck)
        {
            if (myPlayer.isStuck)
            {
                myState     = AIState.IAmStuck;
                chasePlayer = FindClosestPlayer();
            }
        }

        RealizeErrors();
    }
    void OnTriggerEnter2D(Collider2D c)
    {
        if (c.GetComponent <AIP>() != null)
        {
            AIP point = c.GetComponent <AIP>();
            lastNode = point;
            FreezeMovement();

            //usually we want to jump.. UNLESS we are looking for a crate / bomb and the crate / bomb is below us.
            bool shouldJump = point.jump;

            if (myState == AIState.CrateAvailable)
            {
                if (crate != null)
                {
                    if (this.transform.position.y - crate.transform.position.y > 0)
                    {
                        //dont jump
                        shouldJump = false;
                    }
                }
            }
            else if (myState == AIState.IHaveBomb && chasePlayer != null)
            {
                if (chasePlayer != null)
                {
                    if (this.transform.position.y - chasePlayer.transform.position.y > 1)
                    {
                        //dont jump
                        shouldJump = false;
                    }
                }
                //if you are going down to the floor
                if (chasePlayer.lastPoint != null && lastNode != null &&
                    chasePlayer.lastPoint.FLOOR < lastNode.FLOOR)
                {
                    //dont jump!
                    shouldJump = false;
                }
            }
            else if (myState == AIState.BombOnGround)
            {
                if (myLSB != null)
                {
                    if (this.transform.position.y - myLSB.transform.position.y > 0)
                    {
                        //dont jump
                        shouldJump = false;
                    }
                }
            }

            if (shouldJump)
            {
                if (point.type == AIPType.AlwaysLeft)
                {
                    fmState = FMState.JumpToLeft;
                }
                else if (point.type == AIPType.AlwaysRight)
                {
                    fmState = FMState.JumpToRight;
                }
                else if (point.type == AIPType.InheritVelocity)
                {
                    if (myState == AIState.CrateAvailable)
                    {
                        //go to the direction the crate is
                        if (this.transform.position.x - crate.transform.position.x > 0)
                        {
                            //dont jump
                            fmState = FMState.JumpToLeft;
                        }
                        else
                        {
                            fmState = FMState.JumpToRight;
                        }
                    }
                    else if (myState == AIState.IHaveBomb && chasePlayer != null)
                    {
                        //go to the direction the player is
                        if (this.transform.position.x - chasePlayer.transform.position.x > 0)
                        {
                            fmState = FMState.JumpToLeft;
                        }
                        else
                        {
                            fmState = FMState.JumpToRight;
                        }
                    }
                    else if (myState == AIState.BombOnGround && myLSB != null)
                    {
                        //go to the direction the crate is
                        if (this.transform.position.x - myLSB.transform.position.x > 0)
                        {
                            //dont jump
                            fmState = FMState.JumpToLeft;
                        }
                        else
                        {
                            fmState = FMState.JumpToRight;
                        }
                    }
                    else if (wasMovingLeft)
                    {
                        fmState = FMState.JumpToLeft;
                    }
                    else if (wasMovingRight)
                    {
                        fmState = FMState.JumpToRight;
                    }
                }
                else if (point.type == AIPType.OnlyIfGoingLeft)
                {
                    if (wasMovingLeft)
                    {
                        fmState = FMState.JumpToLeft;
                    }
                }
                else if (point.type == AIPType.OnlyIfGoingRight)
                {
                    if (wasMovingRight)
                    {
                        fmState = FMState.JumpToRight;
                    }
                }
            }
            else if (point.move)
            {
                if (point.type == AIPType.AlwaysLeft)
                {
                    fmState = FMState.MoveToLeft;
                }
                else if (point.type == AIPType.AlwaysRight)
                {
                    fmState = FMState.MoveToRight;
                }
                else if (point.type == AIPType.InheritVelocity)
                {
                    if (myState == AIState.CrateAvailable)
                    {
                        //go to the direction the crate is
                        if (this.transform.position.x - crate.transform.position.x > 0)
                        {
                            //dont jump
                            fmState = FMState.MoveToLeft;
                        }
                        else
                        {
                            fmState = FMState.MoveToRight;
                        }
                    }
                    else if (myState == AIState.IHaveBomb && chasePlayer != null)
                    {
                        //go to the direction the player is
                        if (this.transform.position.x - chasePlayer.transform.position.x > 0)
                        {
                            fmState = FMState.MoveToLeft;
                        }
                        else
                        {
                            fmState = FMState.MoveToRight;
                        }
                    }
                    else if (myState == AIState.BombOnGround && myLSB != null)
                    {
                        //go to the direction the crate is
                        if (this.transform.position.x - myLSB.transform.position.x > 0)
                        {
                            //dont jump
                            fmState = FMState.MoveToLeft;
                        }
                        else
                        {
                            fmState = FMState.MoveToRight;
                        }
                    }
                    else if (wasMovingLeft)
                    {
                        fmState = FMState.MoveToLeft;
                    }
                    else if (wasMovingRight)
                    {
                        fmState = FMState.MoveToRight;
                    }
                }
                else if (point.type == AIPType.OnlyIfGoingLeft)
                {
                    if (wasMovingLeft)
                    {
                        fmState = FMState.MoveToLeft;
                    }
                }
                else if (point.type == AIPType.OnlyIfGoingRight)
                {
                    if (wasMovingRight)
                    {
                        fmState = FMState.MoveToRight;
                    }
                }
            }
        }
    }