Hi,
I’m trying to locate if a certain GameObject is interacting with another GO from the bottom, from the left, from the right, or the top.
So what I need is a function that returns from what type of area is the player trying to approach the NPC (Red, Blue, Green, Yellow)
I’ve trying with the following apporch:
void OnTriggerEnter2D(Collider2D collision) {
Vector2 dist = this.transform.position - collision.transform.position;
// Cos
float angX = Mathf.Sqrt((Mathf.Pow(dist.x, 2) + Mathf.Pow(dist.y, 2)));
angX = dist.x / angX;
// Sin
float angY = Mathf.Sqrt((Mathf.Pow(dist.x, 2) + Mathf.Pow(dist.y, 2)));
angY = dist.y / angY;
}
but I don’t know how to proceed or if I’m doing wrong.