Hello, I was wondering if anyone knows how could you use the function workspace:GetPartsBoundInBox to create a box the size it should be on the screen to the world map (with its orientation)
My game is a real time strategy game which means I have to do many things to have a smooth experience, however drag selection has been an issue. I’ve been able to make the dragged box itself but not the system that gets the parts inside the world area (which then I will look thru and select only entities)
Another thing, this is the orientation of the camera at all times as its an isometric view, just if anyone needs it.
Vector3.new(-28.543, -135, -0)
Here is the script:
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local pressing = false
local Ran = false
local HasMoved = false
local PlayerGui = Player.PlayerGui
local Box = PlayerGui:WaitForChild("main").select
local startPos
Mouse.Button1Down:Connect(function()
startPos = Vector2.new(Mouse.X, Mouse.Y)
HasMoved = false
pressing = true
end)
Mouse.Move:Connect(function()
if not HasMoved then
HasMoved = true
end
if pressing then
local currentPos = Vector2.new(Mouse.X, Mouse.Y)
local minPos = Vector2.new(math.min(startPos.X, currentPos.X), math.min(startPos.Y, currentPos.Y))
local maxPos = Vector2.new(math.max(startPos.X, currentPos.X), math.max(startPos.Y, currentPos.Y))
Box.Position = UDim2.new(0, minPos.X, 0, minPos.Y)
Box.Size = UDim2.new(0, maxPos.X - minPos.X, 0, maxPos.Y - minPos.Y)
if not Ran then
Box.Visible = true
Ran = true
end
end
end)
Mouse.Button1Up:Connect(function()
Box.Visible = false
print(HasMoved)
HasMoved = false
Ran = false
pressing = false
end)