Trigger a 3Ds Max animation and sound using a key press

Hi,

I’m trying to trigger a 3ds MAX animation called ‘Take 001’ with a key press ‘s’. I created the following Java script after looking in the forums:

function Update()
{
if(Input.GetButtonDown("s"))
{
animation.Play("Take 001");
}
}

I added the script as a component to the same object in the hierarchy as the animation. However, when I hit play and then ‘s’ nothing happens. Do I need to add something else in the script? Alternatively should I be doing something else with the script?

Many thanks,

Try using GetButton() instead of GetButtonDown().

Try it with Input.GetKeyDown(KeyCode.S)

Hi Cherno,

Many thanks, that answer was spot on.

Cheers,

If you are using Unity’s mecanim, the approach should be different. You’d need to have a trigger or boolean variable in you animator, and if(pressed){ animator.setBool(“name”, bool)}.