Problems making FPS arms and the gun work together
I am making a FPS scene and have my arms and gun models. I am trying to get the movement of the gun and hands to work well.
First attempt----- The first thing I tried was making the gun prefab and the arms prefab separate children of the main camera with them in there correct positions so they follow the camera. This worked for aiming and moving my character/camera around of course but when I started doing their animations I had a problem. Because they are separate children as far as I know they need to have their own animations and own animator components and it is just to hard to get the separate animations to move together properly.
Current attempt---- Currently I have made the gun prefab a child of the camera and the hands a child of the gun. This has worked great so far because I can do both their movements in the same animation clips. I have now come across another problem though. When it comes to moving the gun from hip fire position to aiming position I have the gun as a child of an empty object (gun holder) and I just slerp it to the aiming position. The problem of course is that this makes the arms slerp along with the gun making the upper arms out of line with where the shoulders would be.
How can I make the arms stay where they are when the gun slerps and do the arms movement with an animation, or a different way to do it.
Another option I was thinking about was putting the animator component on the camera and making the gun and arms separate children of the camera again. Would this allow me to still have both their movements in the same animation clips?
Answer by RensDevolp · Apr 16, 2020 at 11:48 AM
There are multiple aproaches to the problem you are describing. The most common one is to animate the entire character in a external animator software like blender. Another option is to download animations with a gun model already in them. You can easily replace the gun with a model of your own.
I'm currently trying out a option i've never used before: inverse kinematics, or IK. This option seems like the solution to what you are trying to accomplish. I have my character set up with the model in t-pose as child and with a separate gun model. Then I use inverse kinematics to put the hands on the correct position. A benefit of this is that you don't have to animate anything (exept for the body, but FPS games mostly use scripted movement instead of root motion so only the arms are modelled) but can just script the gun movement. Hope this gives you inspiration to find a solution for your problem!
Rens
Your answer
Follow this Question
Related Questions
Help With Recoil Script 0 Answers
Rotate limb inside animation 0 Answers
How do I move two first person shooter hands at once using animation? 0 Answers
Walk animation wont play but idle will 0 Answers