- Home /
Controlling Mecanim through javascript?
I have been wrestling with the Mecanim animation system in Unity for the last week and half. I downloaded the Unity tutorial on it, but all the control scripts were in C#, which I am not very good at. After some browsing on the topic, I realized how little information there is when it comes to Mecanim and javascript. I have figured out the blend tree system, but I cannot control the Animator with a script. Could someone explain to me how to change parameters in a blend tree through javascript? I am sure that i'm not the only one that has struggled with this...
please attach an example of a simple parameter change, like transitioning from idle to walking, or walking to turning.
Thanks for the help :)
Answer by HappyMoo · Jan 01, 2014 at 03:33 AM
Nothin in the Animator setup is language specific.
Create your states, your parameters etc.
then you can set the parameters like this from your script:
var anim = GetComponent(Animator);
anim.SetFloat("speed", yourSpeed);
Answer by adnirjhar · Jan 01, 2014 at 04:50 AM
You can always play with the Input.GetAxis("Vertical") and Input.GetAxis("Horizontal"). Create two float parameters and set the transition condition according to the values. Pass the values of the Input and things should work.
Your answer
![](https://koobas.hobune.stream/wayback/20220613125247im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
User Created Animations Not Working With Mecanim 0 Answers
Why doesn't this animation script work? 3 Answers
Animation depending on the Int value 0 Answers
Mecanim not updating script when it switches state? 2 Answers
Attack Animation through Javascript 0 Answers