How to make no building zones for building system?

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.

any ideas?

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.

oh that was an easy solution with the bounding box thanks!

If you have each building in a model, you can use Model:GetBoundingBox() to get a description of a volume containing all of the parts.

1 Like

should i create the bounding box in the server and check if they are touching or just use it without really creating a part?

1 Like

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.

1 Like

Why perform the same check on the client and the server? Server-side checks alone will suffice.

1 Like

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.

That way, the client only sends requests as a verification method to prevent exploits.

Client-side checks can still be bypassed by exploiters.

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.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.