# Making a "square" Vector2 fit a "circle" Vector2?

I currently have some aim acceleration in place for gamepads in my game, but I’m running into a problem.
For the acceleration to trigger, the analog stick has to pass a certain threshold.
The acceleration is done on a per-axis basis so that acceleration can only be interrupted by change to that specific axis (preventing the player from moving the stick along its boundaries and keeping the acceleration active on all axis.) This means I can’t just use the length to test the threshold.
Problem is, I need the Vector2 my input is stored in to function like a square (I think?)

Here’s what it looks like currently:

The black box is the limits of the Vector2, the blue circle is the limit of the analog stick, and the red square is the threshold. Notice how the threshold does not match up with the limits of the analog stick, and in the corners the threshold cannot even be reached.

What I need is this:

But I have a feeling it probably isn’t possible.

I have other ways of hacking the threshold for the acceleration to basically get the effect I want, but I figured it wouldn’t hurt to see if this was possible first.

Thanks

I understand what you are saying (kindof). Is this with a controller or with an on screen analog stick(like you see on mobile games sometimes)

I guess I’m just trying to figure out what you are doing, since I’m thinking either a center point with a distance check or a circle collider that accelerates once you’re outside of it makes some possible choices, but it might not be what you are looking for.

Or do you mean fixing diagonal movement?
as in explained here:

This will convert your circular input to a square input

`````` Vector2 ConvertCircleToSquare(Vector2 input)
{
const float COS_45 = 0.70710678f;

if (input.sqrMagnitude == 0) // Or < EPSILON, Or < inner circle threshold. Your choice.
{
return Vector2.zero;
}

Vector2 normal = input.normalized;
float x, y;

if (normal.x != 0 && normal.y >= -COS_45 && normal.y <= COS_45)
{
x = normal.x >= 0 ? input.x / normal.x : -input.x / normal.x;
}
else
{
x = input.x / Mathf.Abs(normal.y);
}

if (normal.y != 0 && normal.x >= -COS_45 && normal.x <= COS_45)
{
y = normal.y >= 0 ? input.y / normal.y : -input.y / normal.y;
}
else
{
y = input.y / Mathf.Abs(normal.x);
}

return new Vector2(x, y);
}
``````

@MathiasDG Yes! Thank you! That is precisely what I needed.