x


how do I make my character walk?

i want to make an rpg with unity but i dont know how to make my character walk. ive already made my character with a run, walk and idle animation with blender and imported it into unity. but i dont know how to make my character do his animation when i press the buttons on my keyboard. all i know is that its somehow done with scripting, and im hopeless at scripting. so can anyone write me a script or tell me how i would do this?

more ▼

asked Dec 13 '10 at 08:36 PM

hugemaggot gravatar image

hugemaggot
168 40 42 45

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Check out the tutorials. Read and understand what they are doing. They have scripts that do exactly what you are trying to do. Unless you are paying them to do so, you would be hard-pressed to find someone willing to do all the work for you.

Simple code is something along the lines of:

function Update() {
    var v = Input.GetAxis("Vertical");
    if(Mathf.Abs(v) > 0.1f) {
        animation["Walk"].speed = v;
        animation.CrossFade("Walk");
        transform.position.z += v;
    }
    else animation.CrossFade("Idle");
}
more ▼

answered Dec 13 '10 at 08:53 PM

skovacs1 gravatar image

skovacs1
10k 11 25 91

i dont understand the tutorial of lerpz which is the only one that covers animating a character im taking A STRESS HERE MAN ARRRR!!!!! ive been trying to do this for about a week now and im no where closer than where i started please i need help!!!!!!!

Dec 13 '10 at 09:16 PM hugemaggot

If you don't understand the tutorials, rather than shouting and pestering people to do everything for you, try asking about the specific part of the tutorial that is giving you so much grief. Most of the tutorials have scripts called somethingOrOtherAnimation which do pretty much exactly what I've posted. They have some somethingOrOtherController which sets a variable isMoving to true when Mathf.Abs(something) > 0.1f and then in the somethingOrOtherAnimation, they check somethingOrOtherController.isMoving and play the appropriate animation. The 2D platformer tutorial is simplest - start there.

Dec 13 '10 at 09:29 PM skovacs1

im sorry for shouting im was just really angry, sorry again.

Dec 14 '10 at 07:52 AM hugemaggot
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3768
x3721
x722
x205

asked: Dec 13 '10 at 08:36 PM

Seen: 3891 times

Last Updated: Dec 13 '10 at 08:36 PM