Hey, after searching the whole internet and testing things out about 3 weeks I still can't figure out how FPS hands with the gun attached to them are made. Do you: 1. Only use the hands in unity and use IK targets to get the right position for different guns? If yes, how would you make reload animations? 2. Use guns with arms attached? If yes, would you need to change the texture of all guns/arms if you want to implement for example clothing? 3. Only use one pair of hands with many animations for every gun and then attach the active gun to a bone? How would you make reload animations in that case? 4. Use a completely different way? Really need help on this one since I can't go on with the development of my game And Sorry for my terrible English! Yours faithfully Smurf
I've always just either A) Put an empty game object in the palm of the hand and make it a child of the hand bone. or B) make the weapon a child of the hand bone.
In animation clip, add some sort of animation event and swap guns when event is triggered. IK chains are probably are a bad idea and will look awkward. [ This can work, and this is the easiest way. To change clothing you can change mesh or material on the mesh at runtime. This can also work. Reloading animations will be done with animation events. Can't think of any other way. I think you listed all or most of them. https://docs.unity3d.com/Manual/animeditor-AnimationEvents.html Make an event for a moment when weapon changes, when clip is being detached, then hide/show/swap objects on the runtime when the event is received. Having said that, you only need animation events to handle weapon reloading with moving parts/detachable clips. Switching weapons does not require animation events.
I have a script that matches bone names and then parents and positions them. This way, as long as the clothes were made for the figure (in this case, the arms) and you didn't change the bone names, you can simply "conform" the clothes to the arms. I got the idea from Poser and a ragdoll tutorial I watched. This way you only need one set of arms with animations and can have unlimited number of clothes. If you turn off the renderer on the original arms, you can even replace them completely with ease. Code (CSharp): using UnityEngine; using System.Collections; public class ClothesParenter : MonoBehaviour { public Transform[] bones; public Transform[] parentBones; public GameObject parentHip; public GameObject myHip; private bool matched=false; void Awake() { } void Update () { if(matched)return; if(parentHip==null) { parentHip =transform.parent.GetComponentInChildren<MyHip>().gameObject; //create a blank script called "MyHip" and attach to root of bones return; } if (myHip == null) { myHip = GetComponentInChildren<MyHip>().gameObject; return; } if (matched==false)MatchChildrenTransform(); } void MatchChildrenTransform() { matched=true; bones=myHip.GetComponentsInChildren<Transform>(); parentBones=parentHip.GetComponentsInChildren<Transform>(); foreach (Transform trans in bones) { foreach (Transform trans2 in parentBones) { if(trans.name==trans2.name) { trans.parent=trans2; trans.position=trans2.position; trans.rotation=trans2.rotation; } } } } // Update is called once per frame }
I wonder how Nelson Sexton did this in Unturned. Because there you even can make custom guns and stuff for the game and the hands are always perfectly positioned without having any IK targets. Any ideas how that's done?
If you want perfection, you can always build a custom set of animations for every gun. Considering how few unique guns a FPS normally has, and how much screen time guns get, building custom isn't a bad way to go.
I usually just rig the gun and hands in Blender for each weapon. You can use the same hand model for each weapon, it's just going to need different animations. For something that's going to be right in the player's face for most of the game, it's worth putting in extra time and resources.
Thanks for all of your replies! I've tried out almost everything now but I still ain't really satisfied with any of the solutions . I, for example, want the users to be able to create custom guns and stuff but then I realised that then the hand positions wouldn't fit their gun again :/. ANY idea how to make that possible? Thank you so much for any reply!
There is no solution that will satisfy an infinite number of possibilities perfectly. Every FPS I have played had a limited number of guns. Even the ones with player customization, the base gun was still the same and the hands didn't need to move no matter how many modifications were on the gun.