Ejemplo n.º 1
0
    void FixedUpdate()
    {
        if (!damaged)
        {
            isOnGround = Physics2D.OverlapCircle(
                new Vector2(checkGround.position.x,
                            checkGround.position.y), radioG, whatIsGround);

            isOnWall = Physics2D.OverlapCircle(
                new Vector2(checkWall.position.x,
                            checkWall.position.y), radioG, whatIsWall);

            float hor = Input.GetAxis("Horizontal");

            transform.Translate(new Vector3(hor * Time.deltaTime * speed * dir + dash.velocidad(1) * 0.08f, 0, 0));

            if (!isLookingRight && hor > 0)
            {
                isLookingRight = true;
                flip();
                dir = 1;
            }
            if (isLookingRight && hor < 0)
            {
                isLookingRight = false;
                flip();
                dir = -1;
            }
        }
    }