how to add a walking animation when character is moving?

Hi guy, im new to unity 3d and i have a problem . i have a zombie prefab and a walking animation.i want to add that animation when my zombie is moving.

Hi, welcome to unity :slight_smile:

You can make your player animate when moving like this:

    public float stopAnimation = 0.5f;
   
    var directionVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        if ((directionVector.x > stopAnimation || directionVector.x < -stopAnimation) ||
    	    	(directionVector.y > stopAnimation || directionVector.y < -       stopAnimation) ||
   		(directionVector.z > stopAnimation || directionVector.z < -   stopAnimation)) {
        	animation.Blend("YourAnimationNameWalk");
    	 } else {
        	animation.Blend("YourAnimationNameIdle");
    	}

I suggest you read up on what this actually means. Its quite simple, and basic to read. Good Luck.

Remember to check the reference page for quick tips and solutions.

You can also use Unity’s Mecanim to sort of visually “program” your animations and parameters to toggle between animations on a player. You can find more here.

Whoa whoa whoa, misread I thought we were talking about the player… In any case you would use the Animator Component and Move Towards Component…