Hello, I'm developing a build system for a game. It uses snapping and is clamped by the bounds of the plot.
The user also has the ability to rotate the model by 90degrees every time they press 'R'. When facing forward/ backwards, it is totally fine and is bounded well by the grid. However, once it is facing any other direction it is still trying to calculate the clamped position by its default rotation.
I have tried flipping the axis round when rotated but that doesn't work, I've attempted using look vectors and i believe i got close but that didn't work unfortunately.
I was just wondering if anyone knew how i could attempt to go about fixing my solution
--Snapping
x = floor(mouse.Hit.X / spacing + .5) * spacing
z = floor(mouse.Hit.Z / spacing + .5) * spacing
--Grid Clamping
if(plrPlot) then -- NEED TO COMPENSATE FOR ROTATION!
x = clamp(x, (plrPlot.Position.X - plrPlot.Size.X/2) + curStructure.PrimaryPart.Size.X / 2,
plrPlot.Position.X + plrPlot.Size.X / 2) - curStructure.PrimaryPart.Size.X / 2)
z = clamp(z, (plrPlot.Position.Z - plrPlot.Size.Z/2) + curStructure.PrimaryPart.Size.Z / 2,
(plrPlot.Position.Z + plrPlot.Size.Z / 2) - curStructure.PrimaryPart.Size.Z / 2)
end
The above code is the code that only actually works when the model is facing either forwards/backwards. Thank you :)
