Animation Code Problem
Hi i'm animating a simple gun where it has it sound effect when it fires and animation too when you hit the mouse, the problem is that the animation inst working and i'm pretty stuck about this because to me it should work, If you find my error i will happy
Code:
{
if (Input.GetButtonDown("Fire1"))
{
AudioSource CSS_REALISTIC_ = GetComponent<AudioSource>();
CSS_REALISTIC_.Play();
GetComponent<Animation>().Play("AK_Gunfire_Ani(1)");
}
}
//CSS_REALISTIC_ = Audio/Gunshot //Ak_Gunfire_Ani(1) = GunAnimation
Is playing the sound effect the problem or is playing the animation the problem?
Answer by nebulaisrighthere · Jun 18, 2018 at 09:07 PM
And I quote form the original post: "the problem is that the animation inst working " and the title says animation code problem, what do you think? I'm really flabbergasted by that comment. So can you help if its the animation? @applesthepi
Answer by applesthepi · Jun 18, 2018 at 10:41 PM
You need to use the animator componet and call 'Play()' through that componet
GetComponent<Animator>().Play("AK_Gunfire_Ani(1)").Play();
Hope this helps
It didnt work, an error come up as : Error Operator '.' cad to operand of type 'void'
when i put it down. :(