How to put gun in enemy AI hands and adapt it to animation ?

Hello everyone !!!

So, here’s my problem : i’m actualy coding an AI enemy in a FPS game like, but i confront to animating him with a gun in hands, and after reading post and post, i’ve been aware there’s multiple solutions and the one i’ve finally found on my own for the moment is to put the gun in AI hands and change the transform of his weapons depending of the animations played, (here is an exemple) :

``````static private void AnimWalk(Transform M4A8) // Permet de faire tourner l'animation Walk et de regler l'arme avec l'animation
{
anim.SetBool("IsAttacking", false); // ANIMATION Arrete d'attaquer
anim.SetBool("IsIdle", false); // ANIMATION : arrete de rien faire
anim.SetBool("IsWalking", true); // ANIMATION : commence a marcher
Vector3 M4A8position = new Vector3(-0.079f, 1.079f, 0.254f);
M4A8.transform.localPosition = M4A8position;
M4A8.transform.localRotation = Quaternion.Euler(-31.912f, 110.747f, -9.157f);
}
``````

But i think you will agree,i think this solutions take too much ressources for what it is and set not the gun perfectly with the animations

I know there is the IK (Inverse Kinematic) solution but i’m starting in Unity and everything i’ve seen about it let me know that it’s hard to handle IK (unity’s doc say it’s for professional use : https://docs.unity3d.com/455/Documentation/Manual/InverseKinematics.html) and i’ve try to search tutorials about it but nothing really efficient to solve my problem in my case

Maybe there is another solution i don’t know but i’m currently searching

in fact i’m turning to you, asking you if you can help me to solve this problem