Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I use region3 to check for players inside a part, and will region3 work at high speeds?

Asked by
kofe_i 4
4 years ago

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.

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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).

0
I'm checking both altitude and whether the player is in a specific region as well. The point is that the blacking out doesn't occur within a specific area, so people in objects such as planes would not black out when reaching higher altitudes. kofe_i 4 — 4y
0
Are you checking whether the player is inside the plane? A plane isn't simply a geometrical block so its gonna be hard to use Region3 for such a case if so. You should instead just either track if they're touching something part of the plane or just record that they're in that object somehow. Unless your objects are purely blocks, you can use their position and size to set a Region3 up. ArtFoundation 255 — 4y
0
I'm using a block to fill up the interior of the plane.* I just want to know how to check if players are inside a Region3 and if it would still work at high speeds. kofe_i 4 — 4y
Ad

Answer this question