private void FireRotateEvent(Vector2 prev_diff_vector, Vector2 diff_vector, float angle) { Vector3 cross = Vector3.Cross(prev_diff_vector, diff_vector); RotationDirections dir = RotationDirections.CW; if (cross.z > 0) { dir = RotationDirections.CCW; //Debug.Log($"Rotate Counter CW {angle}"); } else if (cross.z < 0) { dir = RotationDirections.CW; //Debug.Log($"Rotate CW {angle}"); } Vector2 midPoint = GetMidPoint(trackedFinger1.position, trackedFinger2.position); GameObject hitObj = GetHit(midPoint); OnRotateEventArg args = new OnRotateEventArg(trackedFinger1, trackedFinger2, angle, dir, hitObj); if (OnRotate != null) { OnRotate(this, args); } if (hitObj != null) { IRotated rot = hitObj.GetComponent <IRotated>(); if (rot != null) { rot.OnRotate(args); } } }
public void OnRotate(OnRotateEventArg args) { float angle = args.Angle * rotateSpeed; if (args.RotationDirection == RotationDirections.CW) { angle *= -1; } Vector3 rot = new Vector3(0, 0, angle); transform.Rotate(rot); }