- Home /
Cant assign animation to script
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...?
As 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 $$anonymous$$ecanim or Legacy.
as perchik and huntsfromshadow says, yes i know how to play the animations, but thats not the problem. Read what i wrote ^^
Answer by haim96 · Feb 27, 2014 at 10:07 PM
i believe you working with legacy animation system.
check this: http://docs.unity3d.com/412/Documentation/Manual/Animations40.html
and this: http://docs.unity3d.com/412/Documentation/Manual/AnimationScripting40.html
Your answer
Follow this Question
Related Questions
Help ThirdPersonController Script 0 Answers
How would I go about making an animation affected by this script? 1 Answer
animations or code? 1 Answer
Attach a animation to 0 Answers
Play animation upon file creation 1 Answer