Hey all,
Fairly new to Unity and just trying to calculate the angle between a point of origin and a target in 2D space. The code I’m using is:
public class BrokenThing : MonoBehaviour
{
public GameObject player;
void Update () {
Vector2 offset = player.transform.position;
Vector2 origin = new Vector2(0, 0) + this.offset;
Vector2 target = new Vector2(0, 0);
float angle = Vector2.Angle(origin, target);
Debug.Log(angle);
}
}
I would expect that when player moves around the angle would update but as it stands the angle always returns 90. I can also see that the x and y values for origin are changing as the player moves around the environment. Could someone let me know where I’m going wrong?