|
| 15 May 2015 08:00 PM |
| Hey, so i'm using CFrame to rotate an unanchored model... But the problem is the model is suppose to kinda just float in place and not really move accept for the brick that controls/rotates it. How can I make it just float? Would it be a bodyposition thing? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 15 May 2015 08:32 PM |
Hey Cold :D
I think you can use a body force for this I am semi asking the same question |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 May 2015 08:39 PM |
| Cold so you want the brick to just float in place? or follow you while floating? |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 08:42 PM |
hopefully my question's answer will help :3 http://www.roblox.com/Forum/ShowPost.aspx?PostID=162211007 |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 15 May 2015 08:44 PM |
| When you want to make a zero gravity model, make sure you add up the total mass of ALL the parts within the model. If you have models within models, you can use a recursive function to access the children of children (and more). |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 08:49 PM |
Sup.
-Le problem is that you are not focusing- KEEP TRYINGGG |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 May 2015 09:02 PM |
| So Ray, how would I get the mass of everything inside one model, then put it in a bodyforce to make it stay in place? |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:21 PM |
local total = 0 for _,k in pairs (model:children()) do total = total + k:GetMass() end force = Vector3.new(0,196.2*total,0) |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:28 PM |
Returns with:
:GetMass() is not a valid member of Model
Plus, inside the model. there are models, how would it calculate the mass of them too? |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 15 May 2015 09:30 PM |
Recursion
local total = 0 function getTotalMass(obj) for i, v in pairs(obj:GetChildren()) do if v:IsA("BasePart") then total = total + v:GetMass() end if #v:GetChildren() > 0 then getTotalMass(v) end end |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:31 PM |
local total = 0 local function addmass(model) for _,k in pairs (model:children()) do if k.ClassName == "Model" then addmass(k) elseif k:IsA("BasePart") then total = total + k:GetMass() end end end
addmass(model) |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:43 PM |
| Ok I got it and it adds the mass.. New problem. Ship now floats up away from anything LOL! (Using future's) |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 09:56 PM |
The BodyForce creation script looks like this:
local Force = Instance.new("BodyForce", game.Workspace.Titanic.BowMotor) local total = 0 local function addmass(model) for _,k in pairs (model:children()) do if k.ClassName == "Model" or k.ClassName == "Split" then addmass(k) elseif k:IsA("BasePart") then total = total + k:GetMass() Force.force = Vector3.new(0,196.2*total,0) end end end addmass(game.Lighting.Titanic) |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 15 May 2015 10:07 PM |
local Force = Instance.new("BodyForce", game.Workspace.Titanic.BowMotor) local total = 0 local function getTotalMass(obj) for i, v in pairs(obj:GetChildren()) do if v:IsA("BasePart") then total = total + v:GetMass() end if #v:GetChildren() > 0 then getTotalMass(v) end end getTotalMass(game.Workspace.Titanic) Force.force = Vector3.new(0,(196.2*total), 0)
If a force is acting on it from underneath and pushing it upwards, or it's getting pushed upwards in anyway for that matter, it's going to continue going upwards. Now I don't necessarily know what the problem is, but you should be taking the mass from the workspace titanic in case of any inconsistency. |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 10:19 PM |
| Hmmm... Still going up instead of floating in place. |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 10:34 PM |
function ModelMass(m) local mass = 0 for i,v in pairs(m) do if m:IsA("BasePart") then mass = mass + v:GetMass() end mass = mass + ModelMass(v) end return mass end |
|
|
| Report Abuse |
|
|
Chrapnel
|
  |
| Joined: 01 Feb 2014 |
| Total Posts: 951 |
|
|
| 15 May 2015 10:44 PM |
| Or you could use BodyPosition. |
|
|
| Report Abuse |
|
|
|
| 15 May 2015 10:46 PM |
| Would BodyPosition allow for the model to continue to be rotated using CFrame after? |
|
|
| Report Abuse |
|
|
| |
|
Chrapnel
|
  |
| Joined: 01 Feb 2014 |
| Total Posts: 951 |
|
|
| 16 May 2015 01:22 AM |
BodyPosition to hold the part in place, BodyGyro to maintain a CFrame (or rotation in your case). |
|
|
| Report Abuse |
|
|
|
| 16 May 2015 01:57 AM |
| When I put them both in, the model just tipped over to the side? How can I make it stay flat? |
|
|
| Report Abuse |
|
|