# Radial clamp while following a crosshair?

I’m making a semi-top down game, and I need a circular(radial) clamp to my crosshair, which I already have. I am using Vector3.ClampMagnitude to clamp it in a radius, but it needs to follow the player. I had a different clamp before, but it only did it square, which looked… odd, so to say.
The code full code is here:

``````void CrosshairMovement()
{
desiredCrosshairPos =
new Vector3(
desiredCrosshairPos.x + Input.GetAxisRaw("Mouse X") * mouseSensitivity,
1.0f,
desiredCrosshairPos.z + Input.GetAxisRaw("Mouse Y") * mouseSensitivity);

desiredCrosshairPos = Vector3.ClampMagnitude(desiredCrosshairPos, 8.0f);

crosshair.transform.position = desiredCrosshairPos;
}
``````

And the code I used before, to clamp it as a rectangle, is here:

``````        desiredCrosshairPos.x = Mathf.Clamp(desiredCrosshairPos.x, transform.position.x - 10, transform.position.x + 10);
desiredCrosshairPos.y = 1.0f;
desiredCrosshairPos.z = Mathf.Clamp(desiredCrosshairPos.z, transform.position.z - 8, transform.position.z + 14);
``````

(This was replaced by Vector3.ClampMagnitude.)

So how do I make it so that the clamp follows the player? As I have it right now the crosshair can move around, but only 8… what’s it called? Pixels? no… Well I hope you understand what I mean. But I want it 8.0f around the Player.

Sorry, I suck at explaining this, but thanks in advance.

Oh, I’ve already got it from this question.

`````` transform.position = transform.position + Vector3.ClampMagnitude(desiredCrosshairPos - transform.position, 8.0f);
``````