void SetCrosshairPosition(bool isUsingMouse) { if (isUsingAutoAim == false) { if (isUsingMouse) { var worldMousePosition = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f)); var facingDirection = worldMousePosition - transform.position; aimAngle = Mathf.Atan2(facingDirection.y, facingDirection.x); if (aimAngle < 0f) { aimAngle = Mathf.PI * 2 + aimAngle; } } else { aimAngle = Mathf.Acos(rightStickPosition.x); if (rightStickPosition.y < 0) { aimAngle = -aimAngle; } } } else { Vector3 targetPos = CustomFunctions.GetClosestPlayerPosition(this.transform.position); if (Spawner.instance.isInZombieMode) { targetPos = CustomFunctions.GetClosestZombiePosition(this.transform.position); } aimAngle = GetAutoAimAngle(targetPos); } //print("Aim Angle : " + aimAngle); if (!crosshairSprite.enabled) { crosshairSprite.enabled = true; } var x = transform.position.x + 1f * Mathf.Cos(aimAngle); var y = transform.position.y + 1f * Mathf.Sin(aimAngle); var crossHairPosition = new Vector3(x, y, 0); crosshair.transform.position = crossHairPosition; }