- Home /
Question by
Ian-McCleary · Aug 28, 2014 at 12:33 AM ·
animationjavascriptcalling
How to call animations in JS
Hi, i would like to know how to call an animation from my Character Motor replacement script. Im pretty sure i have to make variables and call something from either an animator or a game object but the animations themselves are not on the player in any way. If i can call them from the folder thats fine but i believe i can also put them in an animation component (not sure thats why im asking). So how would i go about doing this stuff. I watched the unity mechanim tutorial and it uses C# but i need to know if JS. thanks in advance and the script is below!
// If running is enabled, change to run speed when left shift is pressed:
if (Input.GetKey(KeyCode.LeftShift) && enableRun == true)
{
speed = runSpeed;
}
// If crouching is enabled, change to crouch speed when "c" is pressed:
else if (Input.GetKey("c") && enableCrouch == true)
{
speed = crouchSpeed;
}
// If nothing is pressed, use walkSpeed:
else
{
speed = walkSpeed;
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613161719im_/https://answers.unity.com/themes/thub/images/avi.jpg)