I want to create a placement system similar to roblox islands or roblox skywars with prediction blocks and having the block move 3x3x3 studs with collission detection similar to roblox islands
I have made a placement system but I’m really confused on making it. I’ve tried to see devforum posts but I wasn’t able to make anything. I’m really curious on how you can also stop it from getting out of the player’s magnitude
Screenshots:
Yeah well, the prediction system has to be done on a client side and when player declares specific prediction it should send a placement to the server to create this change.
It seems like it takes the direction the mouse is pointing and then casts a ray towards the nearest part. Depending on which face of the part the ray hits, it makes a bunch of clones in a certain direction. You could use the look vector of the part the ray hit to determine the precise direction you need to go.
The one issue with my theory is the mouse appears to be hovering over nothing, and I’m pretty sure that affects its CFrame. My way is probably not the best way, but for each part placed, I’d have an invisible “mouse hit detection” part surrounding it so I can read the mouse’s CFrame.
If you know you want to place it on the same plane, you can do some math to determine the point where a vector intersects a plane.
If you can find the point on the plane where the vector from the camera in the direction of the mouse (ViewportPointToRay) and the plane that the other parts are on, then you can “snap” that position to the nearest grid coordinate (in this case the nearest set of 4 studs in each axis) and place it there.
Alternatively just have invisible parts around all the existing parts and when a ray hits that part you know you want to place a block there. A bit more wasteful in terms of adding lots of extra instances though.