Thank you for any help or resources, unfortunately the ones I found did not help me since I did not understand the solution or how to implement it in GML. Here is one example, in case it helps explain the question.

Thanks!

Thank you for any help or resources, unfortunately the ones I found did not help me since I did not understand the solution or how to implement it in GML. Here is one example, in case it helps explain the question.

Thanks!

First, I assume that the origin that the view rotates around is not at 0,0. So let's shift everything so that it is. Assuming that you're calling this from each instance, and if not, replace the variables accordingly:

GML:

```
var newX = x - origin_x;
var newY = y - origin_y;
```

GML:

```
var r = point_distance(0, 0, newX, newY);
var theta = point_direction(0, 0, newX, newY);
```

GML:

`theta -= view_angle;`

GML:

`var rotatedY = lengthdir_y(r, theta);`

- Start from the center of the view.
- Move VIEW HEIGHT * 0.5 steps in the ROTATION DIRECTION + 180. (Use
**lengthdir_x**and**lengthdir_y**to go from length / direction to x / y). - This point is the bottom of the view.
- Make a vector in the ROTATION DIRECTION of length VIEW HEIGHT. This is the UP VECTOR.
- For every thing you wanna depth sort, create a vector between the view's bottom we computed before, and its current real room position. This is the POSITION VECTOR.
- Compute the
**dot product**between the UP VECTOR and the POSITION VECTOR. This gives you a number that's bigger, the bigger the parallel component of the position vector with respect to the up vector is. Or in layman's terms, the more "up" something is with respect to the view, the bigger this number is. (If it's facing downwards, the number is negative). - Depth sort using this number, by just sticking a minus sign in front of it.