easy walk animaton script help!

i have been trying to make an easy walk animation script. like final fantasy or most of the old school rpgs. or at least close to it.

    function Update () {
        if(Input.GetButtonDown("a")){
            animation.Play("walk");
        }
        else if(Input.GetButtonUp("d")){
            animation.Stop("walk");
        }
        else if(Input.GetButtonLeft("w")){
            animation.Stop("walk");
        }
        else if(Input.GetButtonRight("s")){
            animation.Stop("walk");
        }
    }

i have a simple walk animation. and my character mesh. but i am not sure how to add the script to it to make him animate and move?

my walk animation is called “walk” and my character mesh is “hero” if that helps?

update: here is the console error i get if i add my script to my character mesh.

UnityException: Input Button l is not setup.
To change the input settings use: Edit → Project Settings → Input
Walk.Update () (at Assets/models/hero/script/Walk.js:2)

update: i found the problem i was adding my FBX to my OBJ modal all i needed was the FBX file what a noob i am lol! thinks guys for all your help!

theres no such fucntion as

Input.GetButtonLeft

if there is up and down. why not left and right? or are you saying pushing the button down?

lionbear,
Its pushing the button down and up.
Button gets the input from the input manager.
In the input manager you can put references to keycodes.
The is a labour saving device if you want port you game to different platforms, or you want to change the keys, or have the user change the keys in game.

and in case there’s a follow up “why?”, think of a game like worms; when space is pressed down the force builds up behind the shot, when space is released (buttonUp) the shot is fired :slight_smile: