I need a formula to split the screen into 4 pieces. From the top left corner to the bottom right one and from the bottom left corner to the top right one. So they are diagonaly split.

```
if (m_MousePositionX * m_pythagoras < m_HalfScreenWidth && m_MousePositionY * m_pythagoras < m_HalfScreenHeight)
```

etc…

Still cant get a correct formula after couple of hours

As you can see i try to call functions depandend on where my mouse position is (Left, top, right or bottom zone of the screen)

Try this:

```
// Convert mouse cursor pos to normalised range: -1 to +1
float x = (m_MousePositionX-m_HalfScreenWidth)/m_HalfScreenWidth;
float y = (m_MousePositionY-m_HalfScreenHeight)/m_HalfScreenHeight;
if (Mathf.Abs(x) > Mathf.Abs(y))
{
if (x>0.0f)
{
// right
}
else
{
//left
}
}
else
{
if (y>0.0f)
{
// up
}
else
{
// down
}
}
```

Vector3 ConvertMousePosToCardinalDirection(Vector3 m_MousePosition)

```
if (Vector3.Dot(m_MousePosition.normalized, Vector3.right) >= 0.5f)
return Vector3.right;
else if (Vector3.Dot(m_MousePosition.normalized, Vector3.left) >= 0.5f)
return Vector3.left;
else if (Vector3.Dot(m_MousePosition.normalized, Vector3.forward) > 0.5f)
return Vector3.forward;
else
return Vector3.back;
```

or you could do

```
Vector3 ConvertMousePosToCardinalDirections (float m_MousePositionX, float m_MousePositionY)
if (Mathf.Abs(m_MousePositionX) > Mathf.Abs(m_MousePositionY))
{
if (m_MousePositionX < 0)
return Vector3.left;
else
return Vector3.right;
}
else
{
if (m_MousePositionY < 0)
return Vector3.back;
else
return Vector3.forward;;
}
```

and change back to down, and forward to up as needed