- Home /
Character controller movement
I am making third person shooter. I want to use character controller, it is given in manual about - input getaxis , horizontal or vertical whatever it is. But my problem is --> I am able to move it correctly but want to play separate animations for movin' forward or backwards. I want a code which moves my player in a specific direction if a key is pressed, not like getaxis so that i can play different animations for different moves. AND USE CHARACTER CONTROLLER. As like transform.Translate but using character controller and Input.GetKey. Make it like
If (Input.GetKey(KeyCode.UpArrow))
{ // code to move forward using character controller not transform.Translate(0,0,0.1)
animation.CrossFade("walk",0.3) }
Answer by biob988 · May 31, 2013 at 02:16 PM
Hi, Seems like you need animation.CrossFade();
An example of its use can be found in the Unity Scripting Ref:
// Makes a character contains a Run and Idle animation
// fade between them when the player wants to move
function Update ()
{
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)
animation.CrossFade("Run");
else
animation.CrossFade("Idle");
}
I have already made the full script of walk, idle and shoot script. What i need is to move using character controller to move in a direction by input.getkey ins$$anonymous$$d of input.getaxis. $$anonymous$$Y REAL PROBLE$$anonymous$$ $$anonymous$$ove character using character controller by Input.Get$$anonymous$$ey ins$$anonymous$$d of Input.GetAxis(Vertical).
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Player Animation and control panel 2 Answers
Third Person Controller 1 Answer
physically realistic animated character movement 3 Answers
independent arm from body - unity2d 0 Answers