Hello. First of all sorry for my weak English. I hope that you can understand what I write bellow 🙂
I working on contra-like shooter game and I have character which can rotate weapon to position of mouse cursor.
I use "SkeletonAnimator" component for accessing to Mecanim animation system for my character.
In order to implement weapon rotation I created 3 animations in Spine: "riffleRotationTop", "riffleRotationMid", "riffleRotationBot". Each of them has exactly one frame and just represent special rotation angle (top, middle and bottom).
Then in animator window in Unity I created special layer "WeaponRotate" and created one blending tree on it. This blending tree has 3 motion fields for these animations and it blends between them by using parameter witch represent angle between weapon's barrel bone position and mouse cursor position.
Results fully expect. and it looks good by itself... BUT the problem is that the barrel of the weapon is not exactly rotated to the mouse position - it is close, but in some moments of animation, rotation angle of weapon looks very wrong. I think that it is normal because Mecanim just blend between animations which has been created in Spine without any respect to the mouse position in the game, but ofcourse it is the big problem.
So my question(s):
What is the best way to do weapon rotation in shooter game?
May it be something what I describe above? But how I can fix problem with wrong angle?
Maybe rotation must be managed by code? (I'm afraid it will be too difficult to make it beautiful and natural).
Thank you in advance. And if it is necessary I can provide pictures of the character, for clarity.