- Home /
Question by
romans8710 · Apr 21, 2020 at 07:54 AM ·
animationtriggergunrecoil
how can I trigger my animation through script?
I just have a simple gun setup and I want to a recoil animation. I have made the animation that simply rotates the gun upwards and downwards quickly however I don't know how to trigger it through script. BTW the animation is supposed to play when the gun is shot and I am using root motion.
Comment
Answer by ccwiegreff · Apr 21, 2020 at 08:13 AM
set animation rig to legacy
public GameObject exampleObj;
public void Update()
{
if (Input.GetKeyDown("e"))
{
exampleObj.GetComponent<Animation>().Play("ObjectAnimation");
}
}