private void SnapAimTowardsTargets() { if (playerMovement == null || player == null) { return; } if (snapDelay > 0f) {// || TutorialLiveClips.runningLiveClips || PlayerRecorder.isRecording) { playerMovement?.RotatePlayer(); return; } PlayerMovement pm = (PlayerMovement)playerMovement; Vector2 stickDirection = pm.lastDirection; if (snapToObject != null) { Vector3 vector = (snapToObject.transform.position - transform.position).normalized; if (stickDirection == Vector2.zero || Mathf.Abs(Vector2.Angle(vector, stickDirection)) < aimAssistThreshold || Mathf.Abs(Vector2.Angle(stickAngleWhenSnapped, stickDirection)) < snapEpsilon) { SnapToGameObject(); } else { snapDelay = delayBetweenSnaps; snapToObject = null; playerMovement?.RotatePlayer(); } } else { if (stickDirection == Vector2.zero) { playerMovement?.RotatePlayer(); return; } Vector2?goalVector = null; Vector2?teammateVector = null; if (goal != null) { goalVector = ((goal.transform.position + Vector3.up) - transform.position).normalized; } if (teammate != null) { teammateVector = (teammate.transform.position - transform.position).normalized; } if (goalVector.HasValue && Mathf.Abs(Vector2.Angle(transform.right, goalVector.Value)) < aimAssistThreshold && Ball.renderer.color == player.team.teamColor.color) { snapToObject = goal; stickAngleWhenSnapped = stickDirection; SnapToGameObject(); } else if (teammateVector.HasValue && Mathf.Abs(Vector2.Angle(transform.right, teammateVector.Value)) < aimAssistThreshold) { snapToObject = teammate; stickAngleWhenSnapped = stickDirection; SnapToGameObject(); } else { playerMovement?.RotatePlayer(); } } }