Trying to make an altitude system which checks if a player is above a specific altitude, and then when they are above that altitude, they will start to black out. However, if they are inside a specific part, they do not black out, for situations such as if the player was inside a plane. Looking around for methods to do this, and Region3 seems like the most promising way. However, I've never bothered to use Region3 in the past, and am completely unaware of how to use it and if it will still work accurately at high speeds (like 5k studs/second for safety). Could someone clarify/help with this? Thank you in advance.
You are only checking altitude and not whether the player is within a specific region as that is what Region3
is named for and to be used for.
A region is not a single number value, it's a 3D space represented between two points whereas an altitude is just used to see how high or low you are in a one-dimensional way.
Thus, you can just use Magnitude or the Y value. However, altitude is relative to where you want it to be. If altitude 0 is at Y coordinate 0
(Y coordinate as up/down), then you only have to check the Y value of the player's position to know what altitude they are.
If it's relative to an object that's Y coordinate isn't at 0
. You have to get the Y
coordinate of the player then add the object's Y coordinate to make up and have your altitude. You can alternatively use .Magnitude
by comparing the object that represents the lowest altitude or the position vector3 that does and the player's position in a subtraction operation then get the magnitude of that for the altitude as well ((player.Pos - lowestAltitudeVector3)
.Magnitude).