The character cannot move when attached with animator controller

HI guys, I am a newbie in using unity2D. I encounter some problems when I try to move the character with UI buttons. I have created two buttons to move right and left and generate some simple animation linkage using the animator controller.

However, when I play in the game scene, the character wont move according to the two buttons but only doing animation itself. Then I try to disable the animator attached on the character, although there are no animation, the buttons work which can control the movement of the character. I have created an empty game object called “frog_player” to hold all the sprites of the characters, and the scripts, collider and rigidbody are attached to the empty game object “frog_player”. I have worked for weeks but cannot look for the solution even the problem itself.

part of the files have been attached and really seek for any opinions to solve that, thank you .

The script of the player is as follows:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class player_controller : MonoBehaviour
{
        public float jumpforce;
        public float speedX;
        public Transform groundcheck;
        public float checkradius;
        public LayerMask whatisgrounded;

        private bool facingright;
        private bool isgrounded;
        private float moveinput;
        private bool jumping;
        private Animator anim;
        private Rigidbody2D rb;

        // Start is called before the first frame update
        void Start()
        {
            anim = GetComponent<Animator>();
            rb = GetComponent<Rigidbody2D>();
            facingright = true;
        }

        // Update is called once per frame
        void Update()
        {
            Moveplayer(moveinput);
            isgrounded = Physics2D.OverlapCircle(groundcheck.position, checkradius, whatisgrounded);

            if (isgrounded == true)
            {
                anim.SetBool("isJumping", false);
            }

            else
            {
                anim.SetBool("isJumping", true);
            }

           rb.velocity = new Vector3(moveinput, rb.velocity.y, 0);
        }

        void Moveplayer(float moveinput)
        {
           
            if (moveinput < 0 && !jumping || moveinput > 0 && !jumping)
            {
                anim.SetBool("isRunning", true);
                flip();
            }

            if (moveinput == 0 && !jumping)
            {
                anim.SetBool("isRunning", false);
            }
           
        }

        private void OnCollisionEnter2D(Collision2D collision)
        {
            if(collision.gameObject.tag == "Ground")
            {
                jumping = false;
            anim.SetBool("isJumping", false);
            }
        }

        void flip()
        {
            if (moveinput > 0 && !facingright || moveinput < 0 && facingright)
            {
                facingright = !facingright;
                Vector3 scaler = transform.localScale;
                scaler.x *= -1;
                transform.localScale = scaler;
            }
        }

        public void walkleft()
        {
            moveinput = -speedX;
        
    }

        public void walkright()
        {
            moveinput = speedX;
       
    }

        public void stopwalking()
        {
            moveinput = 0;
        
    }
    }

4862750–468260–testgame.unitypackage (474 KB)

That happen because the animation is overwriting every change that velocity does. I was researching in forums and for solve this there are a way that is called StateMachineBehaviour script. In this script you can control the state of your animation and add physics. But for do this you need to change the Update Mode to Animate Physics in the Animator.

Sorry for not giving a good answer

Thank you very much Ledesma, that is really helpful for me already. I may get more research on using StateMachineBehaviour to learn more. I am not sure whether I have solved that or not, but after I disable the apply root motion and set the update mode to normal, it seems both the character and button can move accordingly.