[Feature Request] Two-handed weapon IK option for 'support hand'

DankP3

Active member
Apologies if this exists and i haven't strayed on it yet...

Weapons such as Assault rifle are entirely dependent on animation accuracy for gripping of the second hand. With different rigs - for example female UMA2 standard skeleton, the relative positions of the left and right hand drift by as much 5cm between idle rifle hold and aim rifle. The differences between UMA2 male and female are shown below (rifle idle animation), also with a crude IK hack, using an empty transform on the rifle to reference the position and rotation. To note, the errors are exaggerated more when switching to aim mode (not shown).

A simple IK checkbox and inspector picker for the target transform that could be enabled for all two-handed weapons that need support in the item definitions . in most cases this will be IK for the left hand, but it could auto target the IK based on the 'non-parent/supporting hand'.

I would think this useful for many as rigs will vary greatly and the advantage of being built in is ease of weapon swapping.

IKdemo.jpg
 
Yes, i'd think built in support for simple IK with any weapon or associated animations that requires two hands, via a specific target transform would be the simplest....
 
There is a lot included (also, thanks for leaving that UCC review) :)

I'm not sure if the latest version has the fix, but there used to be an issue where the IK would jitter a bit when positioning the hand. This may be fixed in the latest version but if not send me a PM and I'll send you the fixed file.
 
cool thanks….. and review is pending, I feel irresponsible reviewing after 3 sessions with UCC, but trajectory is good....
 
@Justin, so i have 3 issues, perhaps related.

First, i have the jitter on the IK movements, so i guess i need your corrected script.

Second if i set a left hand target transform, it appears to require different settings for the idle and aim animations. Additionally, the IK could not keep the hand in place at extreme aim angles (highest and lowest got progressively worse) (in my crude example above, with positional and rotational weights of 1, all was fine in any circumstance).

Third, there is an option for a second IK target called ".......hint". I cannot find a reference for what this is and defining one and moving it seems to have no impact on hand positioning (all setup being tested with the assault rifle)

Thanks for the help
 
I've sent you a PM with the fixed version.

Second if i set a left hand target transform, it appears to require different settings for the idle and aim animations. Additionally, the IK could not keep the hand in place at extreme aim angles (highest and lowest got progressively worse) (in my crude example above, with positional and rotational weights of 1, all was fine in any circumstance).
Does your transform stay at the same relative position from the weapon for both aim and idle? You should make sure the target is a child of the weapon. Beyond that check your IK weights - the aim ability uses different weights than while idle so chances are it is switching between using the ik target and not using it.

Third, there is an option for a second IK target called ".......hint". I cannot find a reference for what this is and defining one and moving it seems to have no impact on hand positioning (all setup being tested with the assault rifle)
The hint target is taken from Unity's IK system, with the hint for the arm being the elbow.

https://docs.unity3d.com/ScriptReference/AvatarIKHint.html

Start with setting the regular IK target first, and then if you see that you need to adjust the position of the elbow you can go from there.
 
@Justin, thanks, I will probably not be able to look at this until next week.
Even with Aim enabled when angling the aim up or down, the hand would drift from the handle (maybe it is becoming out of reach?), however, just fixing a child transform to the weapon (yes it is a child of fixed local position & rotation) and using default Unity IK has a perfect grip on the handle at all extremities. It seems likely then i haven't implemented the weighting properly in the UCC IK script....so i will investigate this more. Thanks also for the script.
 
@Justin , thanks the script does seem to shut down the jitter.

When applying non-dominant hand IK, this totally overrides reload animations (and any dependent events such as clip detach attach. Is there an inbuilt option to restrict this IK to specific animation sections that could be applied to all animation events on the non-dominant hand? I imagine this would break all such events on all weapons?

I guess non-dominant IK needs to be active on idle and aim, but not reload for all such weapons. is this something that can be built in?

(not really the place for this question, but on continuous fire why would my gun let off a few shots before reload is complete, Nolan doesn't and i cant find the difference).
 
For that I was thinking that you could use the state system. When reload is active you'd set a state to reduce the weight of the arm and then set it back again when reload is complete.
 
@Justin , thanks for the support.
I have figured out the state system from the tutorial and can override the hand weight just fine when in a reload state ( and see the value change in the inspector during reload). However, if there is an ik target set in the weapon, this override does not seem to work. in other words, the CharacterIK hand weight drops to 0 (as seen in the inspector), but the hand largely stays by the assault rifle when it has its own IK target, even though CharacterIK hand weight switches to 0. Is this a bug or am i missing something?
Thanks
 
Looks like I may need to add an option to CharacterIK which allows you to specify if the IK target should be used. I'll take a closer look at it.
 
Hello, I have this problem too, hand weight 0 fixes it but I can't get the state to work, I went to 'States' in the CharacterIK script, and created a new preset Hand Weight = 0, but now I'm not sure how to get that to work when Reload is active. I watched your state tutorial but still the Hand Weight is 1.

1. Should the state be added in CharacterIK ?
2. What should the preset contain I think this is where I am stuck but when I try a preset not created from CharacterIK I get the preset is of the wrong object type, so not sure how to make it set the weight to 0 when reloading.

Any help greatly received.

Thank you,
 
On the item ability for reload it should have a state textbox usually with the default 'Reload'.
You create a new CharacterIK preset as you have done, but it must have the same name. Ie. In this example Reload. That way the correctly named presets are used when the state us set.
 
Hello, ok so I'm feeling really stupid, can you tell me where I'm going wrong...... so on the item which in my case is myRifle, there is the ShootableWeapon script and in that there is a section Reload with 'States' but I can't add my CharacterIK preset there as I get :-

Error: Unable to add preset Reload - the preset doesn't use the same object type.

So clearly I'm in the wrong place, but I still don't know where the right place is, sorry for being stupid I'm sure once i figure it out I will have learned a big lesson on how this works but I just can't figure out where it goes :(

Thank you,
 
Top