- Home /
scripting Animations
My player model and animations are all done in blender with seperate animations, not all are 250 frames (which it seems to play them at automatically)
my Run is 60 frames and should loop can i write this in script maybe?
the majority of the rest are 250
ive tried this method it don't work...
http://unity3d.com/support/documentation/Manual/Animation%20Scripting.html
here's my script...
var walking = false; var aiming = false; var run = false; var idle = true;
function Update () {
if(walking == true && run == false){
animation.CrossFade("fpsWalk", 0.2);
idle = false;
}
else if(walking == true && run == true){
animation.CrossFade("fpsRun", 0.2);
idle = false;
}
else if(aiming){
animation.CrossFade("fpsAim", 0.2);
idle = false;
}
else if(idle){
animation.CrossFade("fpsIdle", 0.2);
run = false;
walking = false;
aiming = false;
}
}
function FixedUpdate(){
if(Input.GetKeyDown("w")){
walking = true;
}
if(Input.GetKeyUp("w")){
walking = false;
}
if(Input.GetKeyDown("q")){
aiming = true;
run = false;
}
if(Input.GetKeyUp("q")){
aiming = false;
}
if(Input.GetButton("Run")){
run = true;
}
else{
idle = true;
}
}
Answer by ScarStudios · May 12, 2013 at 12:56 PM
hi your problem is at the end of ur values of smoothness and speed you need to place f at the end like this:
if(walking == true && run == false){
animation.CrossFade("fpsWalk", 0.2f);
idle = false;
Your answer
Follow this Question
Related Questions
play animation when moving,and idle animation when stand still 1 Answer
Player problem animation 0 Answers
Need a "ghost" script ! 1 Answer
Using multiple buttons in script 3 Answers
Enemy Animation Freezing in first frame 2 Answers