sharky99
|
  |
| Joined: 18 Dec 2008 |
| Total Posts: 3364 |
|
|
| 02 Jan 2014 04:22 PM |
I need the keep the position of Y when I am moving a model (a group of parts) with MoveTo()
for example MoveTo(Vector3.new(workspace.baseplate.Position.X, Model.Position.Y, workspace.baseplate.Position.Z))
So what do I put in for the y position?
~shark
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Jan 2014 04:26 PM |
"Model.Position.Y" Change that to whatever you want |
|
|
| Report Abuse |
|
|
sharky99
|
  |
| Joined: 18 Dec 2008 |
| Total Posts: 3364 |
|
|
| 02 Jan 2014 04:27 PM |
| Models dont acually have a position, do they? |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 02 Jan 2014 04:27 PM |
X = Workspace.baseplate.Position.X Y = Model:GetModelCFrame.p.Y Z = Workspace.baseplate.Position.Z
Model:MoveTo(X,Y,Z) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Jan 2014 04:28 PM |
No, but I was assuming it's a Vector3 ^ And yeah, GetModelCFrame().p |
|
|
| Report Abuse |
|
|
sharky99
|
  |
| Joined: 18 Dec 2008 |
| Total Posts: 3364 |
|
|
| 02 Jan 2014 04:33 PM |
| Alright im gonna try that, trying to check the models "Position" errored |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 02 Jan 2014 04:35 PM |
| Ye. Models just represent multiple parts, and therefore have on single position. GetModelCFrame returns the average position (centre) of all the parts. |
|
|
| Report Abuse |
|
|
sharky99
|
  |
| Joined: 18 Dec 2008 |
| Total Posts: 3364 |
|
|
| 02 Jan 2014 04:55 PM |
yeah, It moves it above ground... I need to move an object so that it is connected to the ground still. Anything for that? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Jan 2014 04:58 PM |
Set it to whatever the ground's y position is (baseplate or whatever you are using) + half of the Y size
local floor = workspace.Ground.Position.Y + (workspace.Ground.Size.Y / 2) |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 02 Jan 2014 05:00 PM |
function moveModel(model, part) local centre = model:GetModelCFrame() local size = model:GetModelSize() local offsets = {} local children = model:GetChildren() for i=1, #children do local CF = children[i].CFrame local sx, sy, sz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = CF:components() local X = math.atan2(-m12, m22) local Y = math.asin(m02) local Z = math.atan2(-m01, m00) offsets[i] = children[i].CFrame.p - centre.p children[i].CFrame = CFrame.new(part.CFRame.p + offsets[i]+Vector3.new(0,size.Y/2,0)+Vector3.new(0,Part.size.Y/2,0)) * CFrame.Angles(X,Y,Z) end end
That's a function I wrote earlier that I've tried to adapt for you. See if it works |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 02 Jan 2014 05:01 PM |
i.e
moveModel(Model, baseplate) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Jan 2014 05:01 PM |
| Why? he only wants to move it, not move and rotate it |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 02 Jan 2014 05:03 PM |
| It doesn't rotate, the angle multiplication keeps the parts rotated through the move. I maybe could have wrote it more efficiently, but it works perfect for me. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Jan 2014 05:05 PM |
You do realize :MoveTo keeps the rotation, right? (Or does it not? I'm pretty sure it does since it's taking a Vector3 value only) |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 02 Jan 2014 05:07 PM |
| No no. It does. I just wrote that function because Move To re-positions parts if they are slightly inside another one. By CFraming each part of the model separately, I get a more accurate move. |
|
|
| Report Abuse |
|
|
sharky99
|
  |
| Joined: 18 Dec 2008 |
| Total Posts: 3364 |
|
|
| 02 Jan 2014 05:08 PM |
| Thanks for the help guys, ill try it out soon. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Jan 2014 05:09 PM |
| Rofl, MoveTo would be more accurate if the PrimaryPart was set |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 02 Jan 2014 05:12 PM |
"This part is the one positioned by the MoveTo method." - Wiki
Huh. I didn't realise that. |
|
|
| Report Abuse |
|
|
sharky99
|
  |
| Joined: 18 Dec 2008 |
| Total Posts: 3364 |
|
|
| 02 Jan 2014 07:39 PM |
| ugh, your script failed horribly. It spread the parts faraway from the baseplate. And the main problem is that the parts are suppose to be unanchored, I am just trying to make a save load feature to save your building stuff and make it load connected to the floor of the garage you spawn in. The problem is that the loaded parts do not connect to the floor making the parts moveable. The moveto() function moves the parts about 0.01 above the baseplate so it does not make joints to the floor when it is loaded. What is the solution? |
|
|
| Report Abuse |
|
|
sharky99
|
  |
| Joined: 18 Dec 2008 |
| Total Posts: 3364 |
|
| |
|
sharky99
|
  |
| Joined: 18 Dec 2008 |
| Total Posts: 3364 |
|
|
| 02 Jan 2014 09:26 PM |
| bump, I really don't know how to make this work |
|
|
| Report Abuse |
|
|
StBashkir
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26171 |
|
|
| 02 Jan 2014 09:30 PM |
| Why not save the Baseplate with them? And when you load the model call :MakeJoints() on it (after parenting it) to get all the joints to be reconnected. |
|
|
| Report Abuse |
|
|
sharky99
|
  |
| Joined: 18 Dec 2008 |
| Total Posts: 3364 |
|
|
| 02 Jan 2014 09:47 PM |
| Just figured it out, when the model falls on the floor, the floor welds itself to the part that touched it. Worked. |
|
|
| Report Abuse |
|
|