protected override Quaternion CalculateTargetRotation(Vector3 startLookPos, Vector3 currentPos, FTail_Point previousTailPoint = null, FTail_Point currentTailPoint = null, int lookDirectionFixIndex = 0) { if (Lock2D) { return(FLogicMethods.TopDownAnglePosition2D(startLookPos, currentPos)); } else { return(base.CalculateTargetRotation(startLookPos, currentPos, previousTailPoint, currentTailPoint, lookDirectionFixIndex)); } }
protected Quaternion CalculateFor2D(FTail_Point tailPoint) { Quaternion targetRotation; if (FullCorrection) { Vector3 startLookPos = tailPoint.BackPoint.Position; Vector3 lookingAt = tailPoint.RotationTargetPos; targetRotation = Quaternion.identity; if (LookUpMethod != FELookUpMethod.Parental) { startLookPos += tailPoint.BackPoint.TransformDirection(tailPoint.BackPoint.LookDirection) * tailPoint.InitBoneLength * tailPoint.ScaleFactor * sensitivityPower; startLookPos -= (tailPoint.BackPoint.PreCollisionPosition - tailPoint.BackPoint.Position) * CollisionSwapping; if (startLookPos - lookingAt != Vector3.zero) { targetRotation = FLogicMethods.TopDownAnglePosition2D(lookingAt, startLookPos); } targetRotation *= Quaternion.FromToRotation(tailPoint.BackPoint.LookDirection, ExtraToDirection); } else // Parental method { startLookPos += tailPoint.BackPoint.TransformDirection(tailPoint.BackPoint.LookDirection) * tailPoint.InitBoneLength * tailPoint.ScaleFactor * sensitivityPower; Vector3 targetPos = lookingAt - startLookPos; Quaternion targetingRot = Quaternion.FromToRotation(tailPoint.BackPoint.TransformDirection(tailPoint.Transform.localPosition), targetPos); targetRotation = targetingRot * tailPoint.BackPoint.Rotation; } if (Curving != Vector3.zero) { float mul = 10 / ((float)tailPoint.index * 4.5f + 1f); targetRotation *= Quaternion.Euler(Curving.y * mul, Curving.x * mul, 0f); } targetRotation *= tailPoint.Correction; } else { targetRotation = Quaternion.identity; Vector3 startLookPos = tailPoint.BackPoint.Position; Vector3 lookingAt = tailPoint.RotationTargetPos; startLookPos += tailPoint.BackPoint.TransformDirection(tailPoint.BackPoint.LookDirection) * tailPoint.InitBoneLength * sensitivityPower; startLookPos -= (tailPoint.BackPoint.PreCollisionPosition - tailPoint.BackPoint.Position) * CollisionSwapping; if (startLookPos - lookingAt != Vector3.zero) { targetRotation = FLogicMethods.TopDownAnglePosition2D(startLookPos, lookingAt); } //targetRotation = Quaternion.LookRotation(startLookPos - lookingAt, tailPoint.BackPoint.TransformDirection(AxisLookBack * Mathf.Sign(FVectorMethods.VectorSum(AxisCorrection)))); if (Curving != Vector3.zero) { float mul = 10f / ((float)tailPoint.index * 4.5f + 1f); targetRotation *= Quaternion.Euler(Curving.y * mul, Curving.x * mul, 0f); } if (ExtraCorrectionOptions) { targetRotation *= Quaternion.FromToRotation(ExtraFromDirection, ExtraToDirection); } } return(targetRotation); }