[Help] How can i check mathematical area?

So i have some area in Decart Coordinates, and i need to check, is player in this area or not.

https://ibb.co/SXrNQN7

So if we have a circle its ez to make “Distance between”, or if we have non-rotated coordinate system we can use “X component” and “Z component” for all 4 walls.

But how to make it with rotated coordinate system?

Thats what task i mean.

Also will be nice if someone say me how to make “Billard” effect. I mean if someone go out of area with some speed, he will be impulsed in mirror-angle with same speed.

Thanks.

Could the Symmetra ultimate rules in this: EWJVA help you get on the right direction? It goes endless on the wall and is based on calculating the distance from a line, but I think you can figure out the restraints to the last dimension.

One, probably inefficient, way of doing this is by rotating the coordinates and checking for the bounds a box.
A simple Google search will give you this formula
(from math - Rotating a Vector in 3D Space - Stack Overflow)

x' = x cos θ − y sin θ
y' = x sin θ + y cos θ

where all ys are z in-game and θ is the angle you want to rotate from.

About the Billard effect, once you notice the player is getting out of bounds you can either apply a force in the opposite direction of their throttle, converted to world space:

// not sure I got all of the parameters for World Vector Of(), but hope it helps
Multiply(World Vector Of(Throttle Of(Event Player), Event Player), -1)

or you can simply get the coordinate of the center of your box and apply a force towards that (which won’t give you the effect you want but it’s good enough for most cases)

This is a working code to detect whether the player is inside or outside the area.

67TB3

The Idea and how it works:
(All vectors are flatened (multiplied with (1, 0, 1)))
At first I create one direction vector from the position of the player to each of the corners of the area. If you draw a picture of this you will see, that in the case that the player is inside the rectangle the direction vectors look like an X, while in the case that the player is outisde the rectangle the direction vectors will all go to one side of the player.
In order to detect whether its case 1 or 2 its enough to sum up the angles between the direction vectors of adjacent corners. If the player is inside the sum will always be = 360°. If the player is outside the sum will always be < 360°.

Usage:

  • Put the corners of the area into global variable A (IMPORTANT: the Y coordinate has to be 0)
  • IMPORTANT: make sure that the corners are in circular order. Example:
    Right:
    0—1
    | . |
    3—2
    Wrong:
    0—1
    | . |
    2—3