How could I make it so in my building system, you cant place buildings in one another or on top of eachother?
I was thinking to check if mouse is hitting a placed building you wont be able to place, but technically you could still place it really close and it will still clip.
You could iterate through every part in the building you’re placing and check if it intersects with any part of the other building(s), or you could make a bounding box part that covers the entirety of each building and check for intersections between bounding boxes.
I’d have the client do the work of checking if the bonding boxes collide, and then have it send a “request to place” to the server, which would in turn check again by the same method to avoid exploiting. You’d have to actually instance a new part for the bounding box no matter what, unless you decide to implement all of the math to detect intersection between two rectangular prisms.
You’d want to do client side checks to show whether or not an object can be placed without sending unnecessary and lengthy requests to the server, saving server compute power, client and server bandwidth, and providing faster results. That way, the client only sends requests as a verification method to prevent exploits.
Yes. I know. The client side check is just there to prevent constant calls to the server so that the server can provide the final verdict based off of the information passed. Client checks would only be done so that a ton of requests aren’t being sent from a legitimate player, and to provide a visualization to the player about whether or not they may place a building.