- Home /
How do you apply animations to characters with FPS input controls?
http://video.unity3d.com/video/7362044/
I've just been watching this video, and I was wondering how to apply animations, since I've applied a controller to my character:
http://i.imgur.com/jjWQR6M.jpg http://i.imgur.com/gnXIlHt.jpg
I was able to apply the idle animation on the player at least, but I wasn't able to apply any animations while using the FPSInputController button scene. I wonder if you can help, because I'm incredibly new to Unity. I've heard so far it has something to do with the scripting.
Answer by greatwhiteshark17283 · Nov 29, 2013 at 10:21 PM
If I were you, I wouldn't use the FPSInputController for a third person game. The Unity Asset store has a third person controller asset.
As far as animating the character, try this script:
var run : String;
var idle : String;
var jump : String;
var attack : String;
var attack2 : String;
private var running : boolean;
private var jumping : boolean;
private var animationToPlay : String;
function Update(){
if(Input.GetKey("up")){
animationToPlay = run;
}
if(Input.GetKey("w")){
animationToPlay = run;
}
if(Input.GetKeyDown("space")){
animationToPlay = jump;
}
if(Input.GetKey("2")){
animationToPlay = attack2;
}
if(Input.GetKey("1")){
animationToPlay = attack;
}
if(Input.GetKeyUp("up")){
animationToPlay = idle;
}
if(Input.GetKeyUp("w")){
animationToPlay = idle;
}
if(Input.GetKeyUp("space")){
animationToPlay = idle;
}
animation.Play(animationToPlay);
}
Good luck with using Unity!