> For the complete documentation index, see [llms.txt](https://levelalfaomega.gitbook.io/unity-mugen/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://levelalfaomega.gitbook.io/unity-mugen/unity-mugen/trigger-list/p2dist.md).

# P2Dist

Returns the distance of P2 from P1, where P1 is the player, and P2 is his opponent.

### Format:&#x20;

&#x20;          P2Dist \[component]

### Arguments:&#x20;

&#x20;          \[component]

&#x20;                     X, Y

### Return type:&#x20;

&#x20;          float

### Error conditions:

&#x20;          none

### Details:

&#x20;          For comparing the Y-distance, P2Dist gives the difference in the heights of the players' Y-axes. A negative value means that P2 is above P1.

&#x20;          For comparing the X-distance, P2Dist gives the X-distance of P2's axis from P1's axis. A positive value indicates P2 is in front of P1. See also P2BodyDist.

> ```
> trigger1 = P2Dist Y <= -12
>   True if P2 is at least 12 pixels higher up than P1.
> ```
