#RightHandIK
1 messages · Page 1 of 1 (latest)
What I did was moved the gun to fit in the right hand then parented the gun to the right hand or you could try making a custom animLayer script to do pretty much the same thing that the leftIKLayer does but for right Hand.
fishgetthirsty is right, just make sure that your custom anim layer for the right hand is executed before the left hand ik
would the arm follow the weapon if I rotate it during an animation through this method?
If the gun is parented to the right hand, yes
@echo chasm did you manage to do the right hand ik layer? Beacuse i did my own layer just copied the leftHandIKLayer script changed the names to "Right" and added a reference to it in the CoreToolKitLib.cs but it doesnt seem to work. I even made sure to put right ik layer before the left ik layer, and my weapon objects are parented to rightHand.
If your weapons are parented to the right hand, and you want to modify its rotation/location, you need to add an empty object for weapons, like gunHolder for instance. Then, in your right hand ik script, before modifying the right hand, make sure to copy rotation/position of the gunHolder, and then set it back after the right hand modifications
did you mean something like this using Kinemation.FPSFramework.Runtime.Core;
using UnityEngine;
namespace Kinemation.FPSFramework.Runtime.Layers
{
public class RightHandIKLayer : AnimLayer
{
public Transform rightHandTarget;
private Transform gunHolderTransform;
public override void OnAnimUpdate()
{
var target = GetGunData().rightHandTarget == null ? rightHandTarget : GetGunData().rightHandTarget;
var rightHand = core.rigData.rightHand.obj.transform;
if (gunHolderTransform == null)
{
gunHolderTransform = GetGunData().gunHolder.transform;
}
var gunHolderRotation = gunHolderTransform.rotation;
var gunHolderPosition = gunHolderTransform.position;
rightHand.position = Vector3.Lerp(rightHand.position, target.position, smoothLayerAlpha);
rightHand.rotation = Quaternion.Slerp(rightHand.rotation, target.rotation, smoothLayerAlpha);
gunHolderTransform.rotation = gunHolderRotation;
gunHolderTransform.position = gunHolderPosition;
}
}
}
yes, this should work fine
i mean. it sort of works but when i pick up a weapon it rotates weirdly
this is with righHandIKLayer off:
i can just rotate it and each weapon too look normally but thats not efficient. Beacuse it f's up the IK's
i mean their transforms
The problem is that the weapon is parented to the right hand. So, instead of using a transform as a target for the right hand, you need to add a LocRot property to the weapon anim data, then instead of just setting rightHand transform, you need to use that LocRot property to translate and rotate bone
Sorry for bothering but im not really that good of a programmer and im not that familiar with the framework yet, could you please modify the script for me? beacuse i tried but it worked really weirdly or just didnt work
Btw. the rightHandIK transform should be parented to the "GunModelRecoilRef" object since my weapon recoil is applied only to that object and by logic all the children of that object. And when the bone uses the LocRot property then it doesnt include that recoil beacuse its a set variable.
but maybe my implementation was just wrong and i can somehow use the LocRot while including the recoil but, i dont know how, or if its even possible.
@stoic sable
@cedar sky Sorry for the delay. You don't have to parent the right hand IK transforms to the gun model itself, as recoil is applied to the hands via IK, and if gun is already parented to the hand bone (which is your case, correct if I'm mistaken) it will work fine
You can't really use the "left hand ik"-like method here, as the right hand also contains keyframed data from your animations, so you need an additive solution. Simply put, you want just to offset the right hand, so it matches the position/rotation of the rightHanfIK game object
And I'm wrong here, in fact you will need to create a right Hand IK empty object and parent it to the gun. And in the anim code, instead of getting the world position/rotation of that object, you will need to get its transform in weapon pivot space, so you will be able to offset right hand. Keep in mind, that when moving the right hand you will move the gun as well