// Update is called once per frame
    void Update()
    {
        if (alive & !atacking)
        {
            walking = agent.remainingDistance > agent.stoppingDistance;
            //Debug.Log(walking);
            if (!atacking)
            {
                playerAnimator.SetBool("walk", walking);
            }

            if (agent.remainingDistance < 3.0f && agent.remainingDistance > 0)
            {
                //Debug.Log(agent.remainingDistance.ToString());
                if (currentPlatform.entity == null)
                {
                    Debug.Log("no entity");
                    currentPlatform.entity = this.gameObject;
                    agent.isStopped        = false;
                    atacking = false;
                }
                else if (currentPlatform.entity.tag == "Snake")
                {
                    Debug.Log("ATACK TO SNAKE");
                    if (!atacking)
                    {
                        playerAnimator.SetTrigger("atack");
                        playerAnimator.SetBool("atacking", true);
                    }
                    atacking = true;
                    currentPlatform.entity.GetComponent <SnakeController>().lookatPlayer();
                    agent.isStopped = true;
                    playerAnimator.SetBool("walk", false);
                }
                else if (currentPlatform.entity.tag == "Lizard")
                {
                    Debug.Log("ATACK TO LIZARD");
                    atacking = true;
                    playerAnimator.SetTrigger("atack");
                    currentPlatform.entity.GetComponent <LizardController>().lookatPlayer();
                    agent.isStopped = true;
                    playerAnimator.SetBool("walk", false);
                }
                else if (currentPlatform.entity.tag == "Spider")
                {
                    Debug.Log("ATACK TO LIZARD");
                    atacking = true;
                    playerAnimator.SetTrigger("atack");
                    currentPlatform.entity.GetComponent <SpiderController>().lookatPlayer();
                    agent.isStopped = true;
                    playerAnimator.SetBool("walk", false);
                }
                else if (agent.remainingDistance < 1.5f && agent.remainingDistance > 0 && pressingButton)
                {
                    agent.isStopped = true;
                    playerAnimator.SetTrigger("pressButton");
                    playerAnimator.SetBool("walk", false);
                    Debug.Log("set trigger i bool");
                    atacking       = true;
                    pressingButton = false;
                }
            }
        }
        if (currentPlatform.tag != "Finish" && !pauseState.GameIsPaused)
        {
            playerAnimator.SetBool("atacking", atacking);
            Plataforma aux = null;
            if (agent.remainingDistance < 0.1f && agent.remainingDistance > 0)
            {
                playerAnimator.SetBool("poweringUp", poweredUp);
            }
            if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W))
            {
                Debug.Log("Up arrow");
                aux = currentPlatform.getPlataformaAdj(0);
            }
            else if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D))
            {
                Debug.Log("Right arrow");
                aux = currentPlatform.getPlataformaAdj(1);
            }
            else if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A))
            {
                Debug.Log("Left arrow");
                aux = currentPlatform.getPlataformaAdj(3);
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S))
            {
                Debug.Log("Down arrow");
                aux = currentPlatform.getPlataformaAdj(2);
            }
            if (aux != null && !poweredUp)
            {
                FindObjectOfType <GameController>().interaccioPlataforma(aux);
            }
        }
        else if (agent.remainingDistance < 0.1f && agent.remainingDistance > 0)
        {
            playerAnimator.SetTrigger("victory");
            alive = false;
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (!started)
        {
            started = !started;
            Start();
        }

        if (!atacking)
        {
            bool walking = (agent.remainingDistance > agent.stoppingDistance);

            if (attackPlatform.entity != null)
            {
                //Debug.Log("atackPlatform entity != null");
                if (attackPlatform.entity.tag == "Player")
                {
                    //Debug.Log("atackPlatform entity.tag = player");
                    agent.SetDestination(attackPlatform.transform.position + offset);
                    //Debug.Log("Kill");
                    if (walking && agent.remainingDistance < 2.0f)
                    {
                        agent.isStopped = true;
                        mAnimator.SetTrigger("attack");
                        atacking = true;
                        Debug.Log("kill player");
                    }
                    else
                    {
                        mAnimator.SetBool("walk", walking);
                    }
                }
                else if (!walking)
                {
                    mAnimator.SetBool("walk", walking);
                }
            }
            else
            {
                mAnimator.SetBool("walk", walking);
            }

            if (startPlatform.entity != null)
            {
                if (startPlatform.entity.tag == "Player")
                {
                    Debug.Log("Kill");
                }
            }
            if (waiting && attackPlatform.getPlataformaAdj(dir).entity != null)
            {
                if (attackPlatform.getPlataformaAdj(dir).entity.tag == "Player")
                {
                    waiting = false;
                    Debug.Log("Al ataque");
                    path.Enqueue(attackPlatform);
                    path.Enqueue(attackPlatform.getPlataformaAdj(dir));
                }
            }
        }
    }