Third Person Perspective
The main responsibility of the Third Person Perspective Item is the correctly spawn/parent item objects in the hierarchy. Unlike the First Person Perspective Item, the Third Person Perspective Item doesn’t need to position the rendered item every frame because the item will be parented to the character’s bone and doesn’t require as much dynamic movement.
All of the animations were made using the rig provided by the character included in the demo scene, Atlas. If the humanoid character that you are using has slightly different proportions compared to the demo rig then the animations won’t precisely match like they do with the demo character. This is just how the retargeting feature works within Unity and for the best results you should use animations that match your character’s rig.
You can also use IK to correct some of the animation issues by using the Non Dominant Hand IK Target field on the Third Person Perspective Item component. This field will use IK to reposition the non-dominant hand of the character. The non-dominant hand is the hand that the item is not parented to. The Non Dominant Hand IK Hint field specifies the location of the hint bone. With Unity’s IK implementation this is the elbow location. This feature only works with humanoid characters.
As an example lets use the Ethan character from the Standard Assets. If we pull this character in and attach an assault rifle you’ll notice that the left hand is moving through the handle:
This can be corrected by assigning a transform to the Non Dominant Hand IK Target field that will use IK to reposition the hand.
In this example a new GameObject was created that is a child of the Assault Rifle.
When using this method to position the character’s non-dominant hand they will have a problem reloading because the IK system will keep their hand in place. You can use the state system to set the Hand Weight of the CharacterIK component to 0 when the Reload ability is active.
When the item is unequipped you may want the item to be holstered instead of disappearing. This can be done by setting the holster target field within the Third Person Item Perspective component.
This holster target can be set one of two ways:
- Assign the Holster Target field directly within the Third Person Perspective Item component. This works best when the item is not added at runtime. The target Transform should be a child of the character’s rig.
- If the Holster Target field is null then the Holster Target ID field can be used. If this ID is not -1 then when the item is added it will look for a holster target based on the ID of the Object Identifier component. The Object Identifier component should be added to a GameObject that is the child of the character’s rig, similar to above.
Use Parent Humanoid Bone
Should the Object object be spawned based on the character’s humanoid bone?
Parent Humanoid Bone
If using the humanoid bone, specifies which bone to use.
Non Dominant Hand IK Target
The location of the non-dominant hand which should be placed by the IK implementation.
Non Dominant Hand IK Target Hint
The location of the non-dominant hand hint which should be placed by the IK implementation.
The transform that the item should be holstered to when unequipped.
The ID of the HolsterIdentifier component that the item should be holstered to when unequipped. This id will be used when holster target is null and the the ID is -1.