protected override void JointUpdate() { if (isNotValid()) { return; } transform.position = Anchor.position; Vector3 P1; Vector3 P2; float radians; int matchedPointCount = MathUtils2.FindLineCircleIntersections(Anchor.position.x, Anchor.position.y, JointLength, TrackFarEdge.position, TrackNearEdge.position, out P1, out P2); switch (matchedPointCount) { case 1: radians = MathUtils2.GetRadiansBetween2Positions(Anchor.position, P1); transform.eulerAngles = new Vector3(.0f, .0f, radians * Mathf.Rad2Deg); break; case 2: radians = MathUtils2.GetRadiansBetween2Positions(Anchor.position, MathUtils2.GetNearestPoint(TrackFarEdge.position, P1, P2)); transform.eulerAngles = new Vector3(.0f, .0f, radians * Mathf.Rad2Deg); break; default: Debug.Log("no point"); break; } }
protected override void JointUpdate() { if (isNotValid()) { return; } float radians = MathUtils2.GetRadiansBetween2Positions(Anchor.position, DestinationTarget.position); transform.position = Anchor.position; transform.eulerAngles = new Vector3(.0f, .0f, radians * Mathf.Rad2Deg); }