Increase size of parts via dragging in game

Getting somewhere I guess. Lil awkward. Any ideas where to go from here?
com-video-to-gif

You need to position the brick in the center of the two points, not at your first point :slight_smile:

That just did the same but in the opposite direction XD

Tile1.Size = Vector3.new(NewVector.X - OriginalVector.X, 0.1, NewVector.Z - OriginalVector.Z)

Unless I misunderstood??

Update

Click = mouse.Button1Down:Connect(function()
		RenderStepped:Disconnect()
		
		local OriginalVector = Tile.Position
		
		RenderStepped = RunService.RenderStepped:Connect(function()
			local NewCFrame = CFrame.new(mouse.Hit.p)
			local NewVector = NewCFrame.Position

			Tile.Size = Round(Vector3.new(NewVector.X - OriginalVector.X, 0, NewVector.Z - OriginalVector.Z), 5, PlayersPlot.Base.Position.Y + 0.1)
		end)
	end)

com-video-to-gif%20(1)
Kinda, eh, not really but ye. If anyone’s got anymore suggestions?

Current problems

  1. Resizing is being done from the centre, instead of having the original part as the corner, like the sims
  2. Part can be made super thin (if the the original and new vector difference is < 5?? then the part should just stay how it normally would be)
  3. Part is being made fat?? As in the y axis has become larger. It should stay flat against the floor

I can’t see your video, are you sure its not just a picture?

com-video-to-gif%20(1)

Hold i have to get another copy for some reason it aint loading the gif

Nvm it doesnt wanna become a gif :confused: basically it doesn’t work. I mentioned the problems here

  1. Resizing is being done from the centre, instead of having the original part as the corner, like the sims
  2. Part can be made super thin (if the the original and new vector difference is < 5?? then the part should just stay how it normally would be)
  3. Part is being made fat?? As in the y axis has become larger. It should stay flat against the floor

I’m not entirely sure what is causing this, I’ll try and script something up myself to see if I can replicate this and or find a solution. I can’t promise it’ll be done tonight though.

1 Like

Any update??? :confused:

Still haven’t figured out a solution to this :confused:

This is what I have so far
com-video-to-gif%20(3)

RenderStepped = RunService.RenderStepped:Connect(function()
	RenderPosition(PlayersPlot, mouse.Hit.p, Tile, LowerX, UpperX, LowerZ, UpperZ)
end)
	
Click = mouse.Button1Down:Connect(function()
	RenderStepped:Disconnect()
	
	local OriginalVector = Tile.Position
		
	RenderStepped = RunService.RenderStepped:Connect(function()
		local NewCFrame = CFrame.new(mouse.Hit.p)
		local NewVector = NewCFrame.Position

        -- Here is where I resize the part
		Tile.Size = Round(Vector3.new(NewVector.X - OriginalVector.X, 0, NewVector.Z - OriginalVector.Z), 5, PlayersPlot.Base.Position.Y + 0.1)
	end)
end)

Just to reitterate, what I’m after is something like the sims floor placement
Video in case you don’t know how the floor placement works


Not worried about the triangle stuff, just after the main placement

Hey, I was trying to do something like this. Not sure if you ever figured it out. I came across this question because I was also looking to see how to do it.

RunService:BindToRenderStep("DrawPart", Enum.RenderPriority.Input.Value, function(Step) 
	local Hit = Mouse.Hit
	local Distance = 0
	if LastHit then Distance = (LastHit.Position - Hit.Position).Magnitude end
	local Center = (LastHit.Position + Hit.Position) / 2
	local DistX = LastHit.Position.X - Hit.Position.X
	local DistZ = LastHit.Position.Z - Hit.Position.Z 
		
	Workspace.BoxSelect.CFrame = CFrame.new(Center)
	Workspace.BoxSelect.Size = Vector3.new( math.abs(DistX), 2,math.abs(DistZ) )
end)

From reading the thread

I indeed positioned a part to the center, and then set the size based on the distance from the initial click and the current mouse position.

:slight_smile:

I ended up giving up :confused: Couldn’t figure it out

There is tutorial for this, you can find some help here.

That’s got nothing to do with what I’m after

To get the exact functionality of that video you can follow my approach but simply snap DistX and DistZ to your grid by modulo.

Wait, the code you supplied works? :open_mouth:

Well the system is same? - placement system - you can customize it to your use…

No it’s not tho. His system is how to place items, I already have that coded in. I’m after how to code the exact floor system as mentioned in my OP

Actually, the system is pretty much the same. It’s a placement system. I’m actually using mine as a selection box. Though I quickly realized a 2D one is better UX. Can’t be bothered to fix it. For that placement of the floor in the video, if you snap the drag to a grid, it constrains it to tiles. I mean you could also probably make it simpler by constraining it to a simple distance instead of splitting up both the X, and the Z. Since doing that allows for free manipulation on both axis. And since it’s a floor, you should be able to set your own Y. These are all size values btw, not position.

I was actually thinking it was another system as well. But once I started thinking of it as a placement system it became easier to manipulate. There are some bugs in my code though. You should really math.abs(DistX) and math.abs(DistZ) if you will be going that route. Otherwise if you use a single distance for the size. (Essentially making a square) the value should always be positive.

RunService:BindToRenderStep("DrawPart", Enum.RenderPriority.Input.Value, function(Step) 
	local Hit = Mouse.Hit
	local Distance = 0
	if LastHit then Distance = (LastHit.Position - Hit.Position).Magnitude end
	local Center = (LastHit.Position + Hit.Position) / 2
	local DistX = math.abs(LastHit.Position.X - Hit.Position.X) -- Allows free manipulation on PartSize X based on distance
	local DistZ = math.abs(LastHit.Position.Z - Hit.Position.Z) -- Allows free manipulation on PartSize.Z

       	
	
	Workspace.BoxSelect.CFrame = CFrame.new(Center)
	Workspace.BoxSelect.Size = Vector3.new( DistX, 2, DistZ )
       -- Uncomment the line below for tiles.
        -- Workspace.BoxSelect.Size = Vector3.new( Distance, 2, Distance ) 
end)

DistX and DistZ uses the difference between the two points in order to find the size. Because of that math.abs is neccessary to handle non-positive vectors.

3 Likes

I was referring to the fact that I already have placement down, my question was aimed at how to make draggable floor be resized. Not how to place the floor.

I will have to check out your code sometime in the future :+1:

1 Like