Subete
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 917 |
|
|
| 30 Aug 2014 10:40 PM |
How do people go about moving a bunch of bricks to one main brick?
I don't mean by teleporting.. I mean like.. floating to the space every tenth of a second or so until they reach the space.
What methods and such do I need for this? |
|
|
| Report Abuse |
|
|
|
| 30 Aug 2014 10:41 PM |
| I think you can just use bodythrusts,bodypositions, or an innumerable amount of stuff |
|
|
| Report Abuse |
|
|
Bobobob12
|
  |
| Joined: 23 Jan 2008 |
| Total Posts: 5350 |
|
|
| 30 Aug 2014 10:46 PM |
like, are we talking in or around the main brick?
because if you want everything to go into a epicenter just use a while loop with a for loop inside
local main = game.Workspace.Main --where you want to move to local model = game.Workspace.Bricks --all the bricks you want moved
local working = true
while working do for x, y in pairs(model:GetChildren()) do working = false if y.Position ~= main.Position then y.CFrame = CFrame.new((CFrame.new(y.Position, main.Position)*CFrame.new(0,0,.1)).p) working = true end end wait() end |
|
|
| Report Abuse |
|
|
Bobobob12
|
  |
| Joined: 23 Jan 2008 |
| Total Posts: 5350 |
|
| |
|
Bobobob12
|
  |
| Joined: 23 Jan 2008 |
| Total Posts: 5350 |
|
|
| 30 Aug 2014 10:50 PM |
local main = game.Workspace.Main --where you want to move to local model = game.Workspace.Bricks --all the bricks you want moved
local working = true
while working do working = false for x, y in pairs(model:GetChildren()) do if (y.Position - main.Position).magnitude > .2 then y.CFrame = CFrame.new((CFrame.new(y.Position, main.Position)*CFrame.new(0,0,-.1)).p) working = true else y.CFrame = CFrame.new(main.Position) end end wait() end |
|
|
| Report Abuse |
|
|
Subete
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 917 |
|
|
| 30 Aug 2014 11:08 PM |
| I'm having issues exiting the while loop.. is there an alternative? I dunno how to make it a coroutine.. The script does work though! |
|
|
| Report Abuse |
|
|
Bobobob12
|
  |
| Joined: 23 Jan 2008 |
| Total Posts: 5350 |
|
|
| 30 Aug 2014 11:14 PM |
coroutine.wrap(function() local main = game.Workspace.Main --where you want to move to local model = game.Workspace.Bricks --all the bricks you want moved
local working = true
while working do working = false for x, y in pairs(model:GetChildren()) do if (y.Position - main.Position).magnitude > .2 then y.CFrame = CFrame.new((CFrame.new(y.Position, main.Position)*CFrame.new(0,0,-.1)).p) working = true else y.CFrame = CFrame.new(main.Position) end end wait() end end)()
now you can do whatever else you want in the script |
|
|
| Report Abuse |
|
|
|
| 30 Aug 2014 11:15 PM |
| It was like lerp or something |
|
|
| Report Abuse |
|
|
|
| 30 Aug 2014 11:16 PM |
This is pulled directly from one of my tweening functions I wrote some time ago.
function tweenPartToPart(secondaryPart,mainPart,time) Spawn(function () local secondary_matrix = {secondaryPart.CFrame:components()} local frames = math.floor(time/0.03) for index1 = 1,frames do local new_matrix = {} main_matrix = {mainPart.CFrame:components()} for index2 = 1,12 do table.insert(new_matrix,secondary_matrix[index2]+((main_matrix[index2]-secondary_matrix[index2]))*(index1/frames)) end secondaryPart.CFrame = CFrame.new(unpack(new_matrix)) wait(0.03) end secondaryPart:Destroy() end) end
secondaryPart is the part you want to move, mainPart is the part you want secondaryPart to move to, time is how long it takes for secondaryPart to get to mainPart. What is really nice about this is that it also mimics rotation, and rather than saving the mainPart's CFrame beforehand, it will continuously reference it in the loop, so the mainPart can be moving and the secondaryPart will follow it as well. |
|
|
| Report Abuse |
|
|
Subete
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 917 |
|
|
| 30 Aug 2014 11:19 PM |
Thanks rolo! You're like the most helpful person on SH lol.
Everyone else was very helpful too though! |
|
|
| Report Abuse |
|
|
|
| 30 Aug 2014 11:19 PM |
| Oh, and you can also remove secondaryPart:Destroy() if you don't want the brick to get destroyed once it gets to the mainPart. |
|
|
| Report Abuse |
|
|
Subete
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 917 |
|
|
| 31 Aug 2014 02:35 AM |
If you want to see my progress on what i'm attempting to script you can take the tool- (coz opensourcing is cool)
It's mostly done, just a few more things to tweek. Press F to use it btw lol.
http://www.roblox.com/TailedBeastBomb-item?id=175467037 |
|
|
| Report Abuse |
|
|