Question by
WANHEDA666 · Sep 10, 2021 at 08:56 PM ·
animationrotationmovement
Inverse kinematic strange rotation
I have an IK solver what should change my player's leg position and foot rotation. Position is working fine, but rotation is weird.
This is the code what takes two legs targets and change their positions.
private void LateUpdate()
{
LegPositionUpdate(RightLeg);
LegPositionUpdate(LeftLeg);
}
private void LegPositionUpdate(Transform leg)
{
Ray ray = new Ray(leg.position + Vector3.up * 0.3f, Vector3.down);
if (Physics.Raycast(ray, out RaycastHit hit, 10, GroundLayer))
{
Debug.DrawRay(ray.origin, ray.direction, Color.red);
leg.position = hit.point;
leg.up = hit.normal;
}
}
Foots are looking like this and I don't know why.
Could anyone help me, please?
screenshot-2021-09-10-at-235305.png
(130.2 kB)
Comment