Large Scale Region Detection

The idea is to have a large number of houses spread out across the map in which the player can enter and trigger a repeating action. My question relates to the performance of such a task and the best way to go about it. How can I have player detection in a large number of regions without hurting performance of my game?

What I mean by region detection
  • player enters the home and fires an event/function*

I have read a few forum posts and have come to the consensus that using Region3 with Raycasting would have the best result. My thought then is where do I run the calculations and how do I run them? I am thinking to run a Region3 emitting from the player which detects a specific part located in each home(region.) Once a home is detected I would use Raycasting to detect when exactly the player enters the home. This would run on the client side. However, I don’t know if it is a wise thing to run region detection on the client side. If my understanding is correct, a player could alter the detection on their client and appear in a different location(please correct me if wrong.)

So I actually have multiple questions related to my idea of how to do this and my understanding of then client-server relationship.

  1. What would be the best method to use to do this. Is Region3 and Raycasting the best?
  2. Does my thought on how to use Region3 and Raycasting work in what I am trying to complete?
  3. Where should I run region detection at? The client or the server?

I hope I explained this well enough to understand. I apologize, I need sleep :laughing:

Please, any and all help is appreciated. Please let me know if I am missing something in my system or if I am off track.

Region3 would definitely work, but I don’t love using Region3 because it isn’t super accurate (can’t have decimals so it’s only accurate to 1 stud I’m pretty sure).

You could use a touched event to detect when they got close to the house, then use a math function to precisely detect whether or not they are actually inside the footprint of the house. Get the relative position of the player to the footprint of the house, then check to see if the X and Z coordinates are inside the boundaries of the footprint. Put that in a loop and it shouldn’t be too intensive if run on the client.

If you use the method I described you definitely wanna put it on the client if you’re gonna be running it several times per second. It depends on how accurate/up-to-date you need it to be. You could run it on the server if you only need to check once every second or so.

Anything that runs on the client can be abused by exploiters, so putting this system on the client would let exploiters control whether or not the server thinks they are in their homes or not. If it’s important for the game to know if they truly are in their homes or not, you should have some form of server validation.

1 Like

Ok so, the rotated region 3 module is great for region detecting. And they could alter the detection on the client- but the great thing is, if you send a message to the server, and the server moves the player, then you can kick people who alter it- how? well, I think that’s rather simple. You know where the area SHOULD be, so if they’re not near it, they can’t be in it, can they? simply use a magnitude function. If you want more complex area detection I suggest reading through Cindering’s BGM freemodel- it’s pretty good at that.