Hello developers!
I’m trying to figure out how to make a system where you place down something, and you can’t place down another object in it. I’m using 2D grid system for the placement system.
Any suggestions?
Hello developers!
I’m trying to figure out how to make a system where you place down something, and you can’t place down another object in it. I’m using 2D grid system for the placement system.
Any suggestions?
Use math.clamp(), ObjectSpace and WorldSpace.
Try the search tool up top with the term “grid placement”. There are quite a few previous posts about this.
How do you expect ToObjectSpace and ToWorldSpace to be used?
Wait so when you place something down, does it put the object into the 2d array? In that case do a simple if check and see if there is an item in that index already. If there is, then don’t place anything, else then add the object to the array and place the model of the object.
Is there a way to detect if there is an object at certain 3d points?
I need a script showing an example of that.
Well there is a lot of factors. Are the objects in a grid like minecraft blocks? What’s the point of a 2d array if they are 3d? I get what you’re asking but there’s are a few ways to go about this.
I’m trying to recreate a city building game and im using a 2 stud grid system and buildings are 2x2 studs, is that enough of info?
It is a lot different, first of all they have 3D system which uses TargetSurface to stack blocks on top, we don’t have that here since we use 2D
Yes, but you can use the Raycast for the part placement and then use blacklists or whitelists to determine if a part can or cannot be placed.
Or just name the placed parts a certain name and by checking to see if the raycast result Name matches the placed part then you wouldn’t place a new part there.
May I have an example of that?
I’m no pro at raycasting, but from the links at create.roblox.com and from a quick search of the forums you’ll find more information than I can provide.
Sadly, it won’t work using raycast.
Please explain exactly what you are trying to do.
From your description you are placing Parts in a grid, similar to a pixel art project.
You don’t want to be able to place Parts on top of or inside of other Parts.
Are you placing them using the mouse Position?
If you answered yes to all the above then you need to explain why Raycasting can’t work?
Okay so, I’m making a city game. I have finished the grid system with X and Z movement only. Let’s say after I place a road, you can’t place another road inside of the road. So basically I want to make a system which occupies places at specific position, if you try to place something in the occupied position it won’t let it place.
So use Mouse.Target
. That will return the item that’s in that location.
For example, make a baseplate named Baseplate as the bottom Part.
Using Mouse
you could get the Instance that the ray hits.
You can check to see if it’s Name is Baseplate.
If it’s “Baseplate” then you can place your item on it, it it isn’t then you can’t place the item.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.