Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hand Move Offset enhancements #14603

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ void UpdateStanding()
}

Vector2 waistPos = waist != null ? waist.SimPosition : torso.SimPosition;
int currentDirectionSign = character.IsFlipped ? -1 : 1;

if (movingHorizontally)
{
Expand Down Expand Up @@ -776,29 +777,6 @@ void UpdateStanding()
currentGroundedParams.LegBendTorque, currentGroundedParams.FootTorque, currentGroundedParams.FootAngleInRadians);
}
}

//calculate the positions of hands
handPos = torso.SimPosition;
handPos.X = -walkPosX * currentGroundedParams.HandMoveAmount.X;

float lowerY = currentGroundedParams.HandClampY;

handPos.Y = lowerY + (float)(Math.Abs(Math.Sin(WalkPos - Math.PI * 1.5f) * currentGroundedParams.HandMoveAmount.Y));

Vector2 posAddition = new Vector2(Math.Sign(movement.X) * HandMoveOffset.X, HandMoveOffset.Y);

if (rightHand != null && !rightHand.Disabled)
{
HandIK(rightHand,
torso.SimPosition + posAddition + new Vector2(-handPos.X, (Math.Sign(walkPosX) == Math.Sign(Dir)) ? handPos.Y : lowerY),
currentGroundedParams.ArmMoveStrength, currentGroundedParams.HandMoveStrength);
}
if (leftHand != null && !leftHand.Disabled)
{
HandIK(leftHand,
torso.SimPosition + posAddition + new Vector2(handPos.X, (Math.Sign(walkPosX) == Math.Sign(-Dir)) ? handPos.Y : lowerY),
currentGroundedParams.ArmMoveStrength, currentGroundedParams.HandMoveStrength);
}
}
else
{
Expand Down Expand Up @@ -845,7 +823,10 @@ void UpdateStanding()
FootIK(foot, footPos, legBendTorque, currentGroundedParams.FootTorque, currentGroundedParams.FootAngleInRadians);
}
}
}

if(!movingHorizontally && !currentGroundedParams.ApplyHandMoveOffsetWhenStationary)
{
for (int i = 0; i < 2; i++)
{
var hand = i == 0 ? rightHand : leftHand;
Expand Down Expand Up @@ -880,6 +861,31 @@ void UpdateStanding()
}
}
}
else
{
//calculate the positions of hands
handPos = torso.SimPosition;
handPos.X = -walkPosX * currentGroundedParams.HandMoveAmount.X;

float lowerY = currentGroundedParams.HandClampY;

handPos.Y = lowerY + (float)(Math.Abs(Math.Sin(WalkPos - Math.PI * 1.5f) * currentGroundedParams.HandMoveAmount.Y));

Vector2 posAddition = new Vector2(currentDirectionSign * HandMoveOffset.X, HandMoveOffset.Y);

if (rightHand != null && !rightHand.Disabled)
{
HandIK(rightHand,
torso.SimPosition + posAddition + new Vector2(-handPos.X, (currentDirectionSign == Math.Sign(Dir)) ? handPos.Y : lowerY),
currentGroundedParams.ArmMoveStrength, currentGroundedParams.HandMoveStrength);
}
if (leftHand != null && !leftHand.Disabled)
{
HandIK(leftHand,
torso.SimPosition + posAddition + new Vector2(handPos.X, (currentDirectionSign == Math.Sign(-Dir)) ? handPos.Y : lowerY),
currentGroundedParams.ArmMoveStrength, currentGroundedParams.HandMoveStrength);
}
}
}

void UpdateStandingSimple()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ public float FootAngle
[Serialize("-0.15, 0.0", IsPropertySaveable.Yes, description: "Added to the calculated hand positions, e.g. a value of {-1.0, 0.0f} would make the character \"drag\" their hands one unit behind them."), Editable(DecimalCount = 2)]
public Vector2 HandMoveOffset { get; set; }

[Serialize(false, IsPropertySaveable.Yes, description: "Should the Hand Move Offset values affect the hands even when stationary?"), Editable]
public bool ApplyHandMoveOffsetWhenStationary { get; set; }

[Serialize(-1.0f, IsPropertySaveable.Yes, description: "The position of the hands is clamped below this (relative to the position of the character's torso)."), Editable(DecimalCount = 2)]
public float HandClampY { get; set; }

Expand Down