Plot system like Lumber Tycoon 2

I would like to know how the block placement system works in lumber tycoon. I mean the way blocks are automatically placed in order to not collide with any other blocks. By this I mean when we select something to place and a shadow appears, what method should I use to decide where the shadow should appear.

I tried making my own version of it but it has plenty of issues when the block doesn’t have a perfect orientation or when 2 blocks are adjacent.

I tried looking on the internet or on the forums but nothing really talks about how blocks should be placed.

2 Likes

This is what I mean by where the shadow should go:
image

We can see that when my mouse is on the wall, the block that I am trying to place is placed on the wall rather than IN the wall. How do games like this calculate the offset needed to place the block correctly?

1 Like

There are alot of great youtube videos on the topic, so I recommend just youtubing it, then breaking down and understanding how the code works

this is 1 of many

3 Likes

All of them are very basic and the only good tutorial that uses a grid system that I found didn’t have the feature for placing blocks on the side of others.

1 Like

Thats where you come in, while yes it would he ideal if everything we needed was in a single YouTube video, but the truth is your going to need to Frankenstein together a bunch of code and make your own system

Through doing this you will understand how the code works and soon enough you will be able to lake it fully on ur own

(TLDR: You gotta code it yourself)

4 Likes

You can use Placement Service

3 Likes

I know I have to code it myself. I was just curious on the different methods I could use to achieve this. But I mean, you’re right, what I am asking for is very specific and the chances that I find someone that actually knows how is very slim.

1 Like

This module is very helpful and polished but it still isn’t what I was specifically looking for. I will be looking into its code to inspire myself tho. Thank you :slight_smile:

2 Likes

Honestly my response was really lazy and I apologize for that

Heres a better resource for Placement systems (a little more in-depth so u can understand how each part works: Placement System Tutorial - P1 (Roblox Studio) - YouTube)

As for what to look into,

1 Like

I actually found the easiest way to make a polished plot building system. The only limitations are blocks that have even sizes. So make sure all of your vector3 are made out of odd numbers.

I basically get the mouse position and the normal of the surface its touching, I then multiply that normal by half of the size of the hitbox of said object I am trying to place. This will give me the offset vector3 needed to push the block onto the surface of whatever wall your mouse is looking at. Simple as that!

Obviously there will be colliding if you put your mouse in the corner of a room since the function will only take into consideration the 1 surface your mouse is looking at but you can fix that by simply displaying the object as red since its an invalid position. After so you just have to connect remoteevents and security checks on the server before spawning the object serverside.

Hope this helped some people!

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