So I’m having a bit of difficulty with correctly rotating a bone the way I need it.
I have no animations to play with so this is purely Transform based movements.
I’m using FinalIK to position the hands in the positions I want. Simple transform manipulation. I set up a Up, Middle, and Down for each Hand position that looked good. Then I made a yDiff variable which is where the mouse is currently. If its in the middle its 0 if its > 0 its moving up… < 0 its down.
Then based on that mouse position ( +/- 5.9f yAxis) I would move a % from that (Upper|Lower) Transform and the Middle Transform. I figure its because I’m manipulating the Euler Angles directly.
Here is a video of what is happening at certain positions : >>Video<<
float yDiff = 0;
yDiff = lookAtTarget.position.y - differenceObject.position.y;
if (yDiff > 0 LeftHand == HandState.Drawn)
{
//Smoothly move to our target position.
float step = Mathf.Abs((yDiff / 5.9f));
//Set our position to the upper position mixed with our middle state based on the step.
_leftHandMovePosition.position = (leftHandLocPistolReady.position * (1 - step)) + (leftHandDrawn_Upper.position * step);
//Calculate the rotation for the step we are in.
Vector3 normalRot = (leftHandLocPistolReady.eulerAngles * (1 - step));
Vector3 upperRot = (leftHandDrawn_Upper.eulerAngles * step);
Debug.Log((normalRot + upperRot));
_leftHandMovePosition.rotation = Quaternion.Euler(normalRot + upperRot);
}
if (yDiff < 0 LeftHand == HandState.Drawn)
{
//Smoothly move to our target position.
float step = Mathf.Abs((yDiff / -5.9f));
//Set our position to the lower position mixed with our middle state based on the step.
_leftHandMovePosition.position = (leftHandLocPistolReady.position * (1 - step)) + (leftHandDrawn_Lower.position * step);
//Calculate the rotation for the step we are in.
Vector3 normalRot = (leftHandLocPistolReady.eulerAngles * (1 - step));
Vector3 lowerRot = (leftHandDrawn_Lower.eulerAngles * step);
Debug.Log((normalRot + lowerRot));
_leftHandMovePosition.rotation = Quaternion.Euler(normalRot + lowerRot);
}
if (LeftHand == HandState.Drawn setLookDir)
{
//setLookDir = false;
leftDrawnRevolver.LookAt(lookAtTarget);
_gunBarrel_Left.LookAt(lookAtTarget);
}
_leftHandPosition.position = Vector3.Lerp(_leftHandPosition.position, _leftHandMovePosition.position, Time.deltaTime * drawSpeed);
_leftHandPosition.rotation = Quaternion.Slerp(_leftHandPosition.rotation, _leftHandMovePosition.rotation, Time.deltaTime * drawSpeed);