Jonateer
|
  |
| Joined: 03 Dec 2008 |
| Total Posts: 114 |
|
|
| 29 Mar 2013 06:02 AM |
After having a look through the many zero gravity scripts available in Free Models, I found that none of them were what I was looking for, and even a few edits here and there couldn't get it to do what I wanted.
Here's what I want it to do: - rather than the weaker gravity the 'zero gravity' scripts create for parts, parts need to drift through space with no apparent source of gravity - if the parts are within certain parameters (such as between 32 and -32 on the X axis), normal gravity affects them - when the part leaves these parameters, the drifting of zero gravity begins until they return to within the parameters
Has anyone made a script similar to this who might be able to advise or suggest anything?
Thanks, Jonateer |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2013 06:06 AM |
| Stuck in a predicament, are we not? |
|
|
| Report Abuse |
|
|
Elfang24
|
  |
| Joined: 04 Feb 2011 |
| Total Posts: 279 |
|
|
| 28 Sep 2014 11:20 AM |
For gravity areas:
if (part.position - planet.position).magnitude < 32 then --planet.position could be any position part.ZeroG:Destroy() else if not part.ZeroG then addZeroG(part) end end
or for inverse square law, and also gravitation toward a specific point (instead of just down)
while true do part.ZeroG.(force of some sort) = vector3.new(1, 1, 1) / (part.position - planet.position)^2 wait() end
I guess a player's rotation, relative to a part, would take some fine matrix coding. I guess the first thing you would need to do is find the closest face, the one toward the player the most, and then fixate the player's rotation to that.
Just thought I would inut some of my ideas, since I have been at this a while. (nothing good yet theough) |
|
|
| Report Abuse |
|
|
Elfang24
|
  |
| Joined: 04 Feb 2011 |
| Total Posts: 279 |
|
|
| 28 Sep 2014 05:20 PM |
Edit to my last post:
If you make a spherical planet then you would only need to make the player's legs face the planet. Easy enough, just use a bodygyro, or a brick attached to the player that orients them that way. |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2014 05:29 PM |
@Elfang There are some issues with rotating a character that uses a humanoid. If you pass a 45-degree angle, your character will automatically trip and you will not be able to move at all. Humanoid physics are very funky. If you want to simulate realistic planetary gravity while also being able to move and see properly, you will have to construct your own camera and movement systems, as well as make a pseudo character without a humanoid so you dont trip. Unless you know how to do all that, there's really no point in trying :/
~The herp lerped a derp~ |
|
|
| Report Abuse |
|
|
Elfang24
|
  |
| Joined: 04 Feb 2011 |
| Total Posts: 279 |
|
|
| 28 Sep 2014 06:08 PM |
@filip Thanks for the info. I tried fiddling around with this method a while back, and ran into several animation/character physics errors, plus the camera only rolls like 2 radians so that screwed it up a lot. |
|
|
| Report Abuse |
|
|
Elfang24
|
  |
| Joined: 04 Feb 2011 |
| Total Posts: 279 |
|
|
| 19 Oct 2014 08:36 PM |
--PERFECT ZERO WITH CELESTIAL BODY ATTRACTION:
--The Replicator Script
function scan(obj) local c = obj:GetChildren() for i = 1, #c do if c[i]:IsA("BasePart") and c[i].Name ~= "Planet" and not c[i]:FindFirstChild("ZeroGravity") then local s = script.ZeroGravity:Clone() s.Parent = c[i] s.Disabled = false elseif c[i]:IsA("Model") or c[i]:IsA("Hat") then scan(c[i]) end c[i].ChildAdded:connect(function() scan(c[i]) end) end end scan(game.Workspace) game.Workspace.ChildAdded:connect(function(p) scan(p)end)
----Cut Here--------------------------------------------------------------------- --The Zero G Script
creatingNew = false script.Parent.Anchored = true
function getCelestBodies(obj) local t = {} local c = obj:GetChildren() for i = 1, #c do if c[i]:IsA("BasePart") and c[i].Name == "Planet" then table.insert(t, #t+1, c[i]) elseif c[i]:IsA("Model") then getCelestBodies(c[i]) end end return t end
function newForce() if creatingNew then return end creatingNew = true script.Parent.Anchored = true script.Parent.Velocity = Vector3.new(0, 0, 0) ZeroG = Instance.new("BodyForce") ZeroG.Name = "ZeroG" ZeroG.Parent = script.Parent ZeroG.force = Vector3.new(0, 196.2, 0) * script.Parent:GetMass() script.Parent.Anchored = false creatingNew = false end
while wait() do if script.Parent:FindFirstChild("Gravity") then script.Parent.Gravity:Destroy() end if not script.Parent then break end ZeroG = script.Parent:FindFirstChild("ZeroG") if (ZeroG == nil) then newForce() else local t = getCelestBodies(game.Workspace) local a = Vector3.new() if #t ~= 0 then for i = 1, #t do if t[i].Name == "Planet" then a = a + (t[i].Position - script.Parent.Position) * (1/(t[i].Position - script.Parent.Position).magnitude^2) * t[i]:GetMass() end end ZeroG.force = (Vector3.new(0, 196.2, 0) * script.Parent:GetMass()) + a else--if #t == 0 or script.Parent.Name == "HumanoidRootPart" then ZeroG.force = (Vector3.new(0, 196.2, 0) * script.Parent:GetMass()) end end end |
|
|
| Report Abuse |
|
|