If you have played Bedwars, you know how smooth the block placement system is. I am trying to create a preview system similar to Bedwars, but I am having trouble getting the to create.
Here’s a post which someone has made which is quite similar to yours. I’d check it out because it has a solution:
doesn’t seems to be work smoothly and perfectly
He means it’s a good starting point to start your work from. Then adjust for the desired effect
Do you have any suggestions for fixing this code snippet: Vector3.new(roundToStep(Mouse.Hit.Position.X, 4), 0, roundToStep(Mouse.Hit.Position.Z, 4))
? Currently, the y value is set to zero, which means the object will always remain stuck to the floor. This issue prompted me to create this forum.
Yeah, maybe try raycasting downwards on the part to find the surface position on the ground. Then set the Y to that position + half of the Y size for the part.
Instead of using raycasting, I believe I can use Mouse.Target
to obtain the part that the mouse is currently hovering over. Afterwards, I can retrieve the height of the block by accessing the Size.Y
property of the target part.
Why use mouse.target for this though? If you’re trying to find the Y position for the part, you should raycast down from that part
When the player is placing a block, the mouse pointer hovers downwards, which allows me to obtain the block directly below. Although I could use raycasting to achieve this, it would require writing more code, and I’m feeling a bit lazy
If your mouse is hovering over a wall or anywhere not on the ground that might not work