Hello, I’m having a problem calculating an angle between 2 directions.

My scene is made of 3D cubes (1x1) and a character.

I want to calculate the angle between two adjacent cubes in relation to the character transform.forward, in screen-space as illustrated below.

The cubes are not touching each-other physically, they are separated as you can see in the editor view.

Anyway, in the 3rd picture (explanation) the dark blue line represents the character’s forward vector. This vector is the one I would like to be the origin of the angle calculation (clock-wise).

The two green dots represent the cubes position (1 and 2).

The light blue is de direction between two points.

The pink/magenta line represents the desired calculated angle.

This is what I got so far:

I convert each cube position to screen-space:

```
Vector2 cube1_2D = camera.WorldToScreenPoint(cube1.position);
Vector2 cube2_2D = camera.WorldToScreenPoint(cube2.position);
```

After that I establish the origin using the characters position + its forward direction:

```
Vector2 character2D = camera.WorldToScreenPoint(character.position);
Vector2 characterForward2D = camera.WorldToScreenPoint(character.position + (1 * character.forward));
Vector2 origin = (characterForward2D - character2D).normalized;
```

After that I calculate the direction of the two points:

```
Vector2 target = (cube2_2D - cube1_2D).normalized;
```

Because of the way unity handles Vector2.Angle(), I use two variables to make the angle go from 0 to 360.

```
float sign = target.y >= 0 ? 1 : -1;
float offset = sign >= 0 ? 0 : 360;
```

And finally the angle is calculated:

```
float angle = Vector2.Angle(origin, target) * sign + offset;
```

The result should be 270 but I get 120.

If somebody can help me with this problem I would appreciate it very much.