So, i coded a basic script, that plays a walking animation when i move, and an idle animation, when i not moving. I think i coded it correctly, but i dont know. Here is the code i wrote:
var idleanim : Animation;
var walkanim : Animation;
function Start () {
}
function Update () {
//Input key "w"
if (Input.GetKeyDown("w")) {
}
if (Input.GetKeyUp("w")) {
}
//Input key "a"
if (Input.GetKeyDown("a")) {
}
if (Input.GetKeyUp("a")) {
}
//Input key "s"
if (Input.GetKeyDown("s")) {
}
if (Input.GetKeyUp("s")) {
}
//Input key "d"
if (Input.GetKeyDown("d")) {
}
if (Input.GetKeyUp("d")) {
}
}
But for some reason when i try to assign the animation to the script it won’t let me.
The animation is of course a .anim
All your code does is look for keypresses, but does nothing with animation...?
– perchikAs perchik says your code isn't doing any animation code. You have to tell Unity to actually play animations. How depends on if you are using Mecanim or Legacy.
– huntsfromshadowas perchik and huntsfromshadow says, yes i know how to play the animations, but thats not the problem. Read what i wrote ^^
– aj2001jkj