- Home /
setting animation transition times to joystick float values
I don't understand how to set the blend times between animation states to my joystick float values. As of now, if I quickly press right on the joystick and let go, the transition plays through the entire animation before playing it again back to idle. But I only want it to play the portion of the animation blend equivalent to how far I pressed the joystick over.
This was easy to solve in the blendtrees, (which I'm showing in the code below) as I assigned the joystick float values to the float animation parameters. I need to be able to do the same thing but between animation states.
I assume something with anim.crossfade? I just don't know how to combine the old legacy code with mecanim... or even if I should. I feel like there should be a better way.
void Start (){
anim = GetComponent<Animator> ();
}
void Update (){
float throttles = (Input.GetAxis ("Throttle2"));
float yaws = (Input.GetAxis ("Yaw"));
float pitchs = (Input.GetAxis ("Pitch"));
float rolls = (Input.GetAxis ("Roll"));
float strafes = (Input.GetAxis ("Strafe"));
float upDown = (Input.GetAxis ("Thrust"));
anim.SetFloat ("PitchP", pitchs, .3f, Time.deltaTime);
anim.SetFloat ("ThrustP", throttles, 2f, Time.deltaTime);
anim.SetFloat ("RollP", rolls, .3f, Time.deltaTime);
Your answer
Follow this Question
Related Questions
Benefits of root motion 1 Answer
Animation and joystick Input 1 Answer
Handling input, movement, animation with scripts? 1 Answer
Mecanim Axis Randomize Input Problem 0 Answers
Clear mecanim trigger input? 1 Answer